From 04938faeeb4b28c5791029a2542848534ac83b17 Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Tue, 20 Jun 2023 16:32:51 -0400 Subject: [PATCH] format-cpp: run clang-format in parallel MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Use the -P option of GNU xargs to run multiple instances of clang-format in parallel, which speeds up the execution quite a bit (depending on the number of cores, of course). Inspired by this babeltrace commit: http://git.efficios.com/?p=babeltrace.git;a=commit;h=66c3bce11973e6e96a3791c378a9e5f98ddaa280 Change-Id: I201535244ef4c3614dfd742ae6f1c427994e6147 Signed-off-by: Simon Marchi Signed-off-by: Jérémie Galarneau --- format-cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/format-cpp b/format-cpp index d7155b21d..17275de77 100755 --- a/format-cpp +++ b/format-cpp @@ -38,7 +38,7 @@ format_cpp() { # shellcheck disable=SC2086 find "$root_dir" -path './src/vendor' -prune \ -o -type f \( -name '*\.h' -o -name '*\.hpp' -o -name '*\.c' -o -name '*\.cpp' \) \ - -not -path '*/\.*' -print0 | xargs -n1 -0 $formatter -i --style=file --fallback-style=none + -not -path '*/\.*' -print0 | xargs -P$(nproc) -n1 -0 $formatter -i --style=file --fallback-style=none } if [[ -n "$FORMATTER" ]]; then -- 2.34.1