Batch up to 64 files per clang-format to speed it up (#4639)

This will make `Invoke-CodeFormat` less bad.
This commit is contained in:
Dustin L. Howett (MSFT) 2020-02-19 05:47:56 -08:00 committed by GitHub
parent 8392d6b647
commit deccf7e12b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 2 deletions

View file

@ -6,6 +6,7 @@ jobs:
steps:
- checkout: self
fetchDepth: 1
submodules: false
clean: true

View file

@ -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 $_
}