From b11c2c28389b7b2baffb4d849f92a094cdfdde28 Mon Sep 17 00:00:00 2001 From: Daniel Jasper Date: Fri, 19 Jul 2013 09:30:44 +0000 Subject: [PATCH] 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. llvm-svn: 186660 --- clang/tools/clang-format/clang-format.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/clang/tools/clang-format/clang-format.py b/clang/tools/clang-format/clang-format.py index 60e2e55..29be72e 100644 --- a/clang/tools/clang-format/clang-format.py +++ b/clang/tools/clang-format/clang-format.py @@ -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):] -- 2.7.4