r186660 - Improve clang-format vim integration.

Daniel Jasper djasper at google.com
Fri Jul 19 02:30:44 PDT 2013


Author: djasper
Date: Fri Jul 19 04:30:44 2013
New Revision: 186660

URL: http://llvm.org/viewvc/llvm-project?rev=186660&view=rev
Log:
Improve clang-format vim integration.

The previous line-by-line replacement causes vim to take a long time if
the foldmethod is set to 'syntax'. This should significantly improve
performance in that case.

Modified:
    cfe/trunk/tools/clang-format/clang-format.py

Modified: cfe/trunk/tools/clang-format/clang-format.py
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-format/clang-format.py?rev=186660&r1=186659&r2=186660&view=diff
==============================================================================
--- cfe/trunk/tools/clang-format/clang-format.py (original)
+++ cfe/trunk/tools/clang-format/clang-format.py Fri Jul 19 04:30:44 2013
@@ -71,8 +71,8 @@ else:
   output = json.loads(lines[0])
   lines = lines[1:]
   if '\n'.join(lines) != text:
-    for i in range(min(len(buf), len(lines))):
-      buf[i] = lines[i]
+    common_length = min(len(buf), len(lines))
+    buf[:common_length] = lines[:common_length]
     for line in lines[len(buf):]:
       buf.append(line)
     del buf[len(lines):]





More information about the cfe-commits mailing list