]> granicus.if.org Git - clang/commitdiff
Improve clang-format vim integration.
authorDaniel Jasper <djasper@google.com>
Fri, 19 Jul 2013 09:30:44 +0000 (09:30 +0000)
committerDaniel Jasper <djasper@google.com>
Fri, 19 Jul 2013 09:30:44 +0000 (09:30 +0000)
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@186660 91177308-0d34-0410-b5e6-96231b3b80d8

tools/clang-format/clang-format.py

index 60e2e550289c5e15644a60a746af08b8577212b5..29be72e176b675b0333c96e34eb97efcaf085a9a 100644 (file)
@@ -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):]