From deccf7e12bd5a7d3ab2193156f348d3cd3bbb124 Mon Sep 17 00:00:00 2001 From: "Dustin L. Howett (MSFT)" Date: Wed, 19 Feb 2020 05:47:56 -0800 Subject: [PATCH] Batch up to 64 files per clang-format to speed it up (#4639) This will make `Invoke-CodeFormat` less bad. --- build/pipelines/templates/check-formatting.yml | 1 + tools/OpenConsole.psm1 | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/build/pipelines/templates/check-formatting.yml b/build/pipelines/templates/check-formatting.yml index b60c6041a..f8b513cf4 100644 --- a/build/pipelines/templates/check-formatting.yml +++ b/build/pipelines/templates/check-formatting.yml @@ -6,6 +6,7 @@ jobs: steps: - checkout: self + fetchDepth: 1 submodules: false clean: true diff --git a/tools/OpenConsole.psm1 b/tools/OpenConsole.psm1 index 15d3d1b60..bef3078a0 100644 --- a/tools/OpenConsole.psm1 +++ b/tools/OpenConsole.psm1 @@ -326,11 +326,21 @@ function Invoke-ClangFormat { [string[]]$Path ) + Begin { + $BatchSize = [int]64 + $Paths = @() + } + Process { ForEach($_ in $Path) { + $Paths += Get-Item $_ -ErrorAction Stop | Select -Expand FullName + } + } + + End { + For($i = [int]0; $i -Lt $Paths.Length; $i += $BatchSize) { Try { - $n = Get-Item $_ -ErrorAction Stop | Select -Expand FullName - & "$env:OpenconsoleRoot/dep/llvm/clang-format" -i $n + & "$env:OpenconsoleRoot/dep/llvm/clang-format" -i $Paths[$i .. ($i + $BatchSize - 1)] } Catch { Write-Error $_ }