Merge pull request #228 from jwittner/dev/improveSetupSearchSpeed

Performance enhancements for Get-UnitySetupInstance
This commit is contained in:
Josh Wittner 2021-07-07 11:27:26 -07:00 коммит произвёл GitHub
Родитель 782e8a7b3f f6f807f6cf
Коммит 0505144385
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
1 изменённых файлов: 18 добавлений и 4 удалений

Просмотреть файл

@ -1265,10 +1265,24 @@ function Get-UnitySetupInstanceVersion {
}
# Search through any header files which might define the unity version
Write-Verbose "Looking for .h files with UNITY_VERSION defined under $path\Editor\ "
$headerMatchInfo = Get-ChildItem -Path "$path\Editor\*.h" -Recurse -ErrorAction Ignore -Force -File |
Select-String -Pattern "UNITY_VERSION\s`"(\d+\.\d+\.\d+[fpba]\d+)`"" |
Select-Object -First 1
[string[]]$knownHeaders = @(
"$path\Editor\Data\PlaybackEngines\windowsstandalonesupport\Source\WindowsPlayer\WindowsPlayer\UnityConfigureVersion.gen.h"
)
foreach ($header in $knownHeaders) {
Write-Verbose "Looking for UNITY_VERSION defined in $header"
if (Test-Path -PathType Leaf -Path $header) {
$headerMatchInfo = Select-String -Path $header -Pattern "UNITY_VERSION\s`"(\d+\.\d+\.\d+[fpba]\d+)`""
}
}
if ($null -eq $headerMatchInfo) {
Write-Verbose "Looking for .h files with UNITY_VERSION defined under $path\Editor\ "
$headerMatchInfo = do {
Get-ChildItem -Path "$path\Editor\*.h" -Recurse -ErrorAction Ignore -Force -File |
Select-String -Pattern "UNITY_VERSION\s`"(\d+\.\d+\.\d+[fpba]\d+)`"" |
ForEach-Object { $_; break; } # Stop the pipeline after the first result
} while ($false);
}
if ( $headerMatchInfo.Matches.Groups.Count -gt 1 ) {
Write-Verbose "`tFound version!"