[Bf-blender-cvs] [6366dec69ff] temp-clang-format: Clang-format: make format fixes and performance improvements for Windows.
Brecht Van Lommel
noreply at git.blender.org
Fri Mar 22 15:36:54 CET 2019
Commit: 6366dec69fff8369256f83ba29136d6755412d0d
Author: Brecht Van Lommel
Date: Fri Mar 22 15:14:14 2019 +0100
Branches: temp-clang-format
https://developer.blender.org/rB6366dec69fff8369256f83ba29136d6755412d0d
Clang-format: make format fixes and performance improvements for Windows.
Fixes by Ray Molenkamp.
===================================================================
M clang-format-paths.py
===================================================================
diff --git a/clang-format-paths.py b/clang-format-paths.py
index 15e1777bc1e..18c52690200 100755
--- a/clang-format-paths.py
+++ b/clang-format-paths.py
@@ -48,8 +48,6 @@ extensions = (
ignore_files = {
"intern/cycles/render/sobol.cpp", # Too heavy for clang-format
}
-if os.sep != "/":
- ignore_files = set(f.replace("/", os.sep) for f in ignore_files)
print("Operating on:")
for p in paths:
@@ -96,10 +94,8 @@ def clang_format_version():
return version
-def clang_format_file(f):
- cmd = (
- CLANG_FORMAT_CMD, "-i", "-verbose", f.encode("ascii")
- )
+def clang_format_file(files):
+ cmd = ["clang-format", "-i", "-verbose"] + files
return subprocess.check_output(cmd, stderr=subprocess.STDOUT)
@@ -109,8 +105,14 @@ def clang_print_output(output):
def clang_format(files):
pool = multiprocessing.Pool()
- for f in files:
- pool.apply_async(clang_format_file, args=[f], callback=clang_print_output)
+
+ # Process in chunks to reduce overhead of starting processes.
+ cpu_count = multiprocessing.cpu_count()
+ chunk_size = min(max(len(files) // cpu_count // 2, 1), 32)
+ for i in range(0, len(files), chunk_size):
+ files_chunk = files[i:i+chunk_size];
+ pool.apply_async(clang_format_file, args=[files_chunk], callback=clang_print_output)
+
pool.close()
pool.join()
More information about the Bf-blender-cvs
mailing list