diff --git a/build.ps1 b/build.ps1 index 915e8db..ad01962 100644 --- a/build.ps1 +++ b/build.ps1 @@ -10,6 +10,12 @@ $CLIRoot = Join-Path $RepoRoot 'cli' $DotNetExe = Join-Path $CLIRoot 'dotnet.exe' $NuGetExe = Join-Path $RepoRoot '.nuget\nuget.exe' + +if (Test-Path $ArtifactsDir) +{ + rm -r $ArtifactsDir -Force | Out-Null +} + Function Error-Log { param( [string]$ErrorMessage, @@ -31,8 +37,6 @@ Function Trace-Time() { $Global:LastTraceTime = Get-Date -rm -r $ArtifactsDir -Force | Out-Null - New-Item -ItemType Directory -Force -Path $CLIRoot | Out-Null New-Item -ItemType Directory -Force -Path $ArtifactsDir | Out-Null diff --git a/src/json-ld.net/Core/JsonLdUtils.cs b/src/json-ld.net/Core/JsonLdUtils.cs index fc07804..75f7928 100644 --- a/src/json-ld.net/Core/JsonLdUtils.cs +++ b/src/json-ld.net/Core/JsonLdUtils.cs @@ -88,14 +88,16 @@ public static bool DeepCompare(JToken v1, JToken v2, bool listOrderMatters) { JArray l1 = (JArray)v1; JArray l2 = (JArray)v2; - if (l1.Count != l2.Count) + var l1Count = l1.Count; + var l2Count = l2.Count; + if (l1Count != l2Count) { return false; } // used to mark members of l2 that we have already matched to avoid // matching the same item twice for lists that have duplicates - bool[] alreadyMatched = new bool[l2.Count]; - for (int i = 0; i < l1.Count; i++) + bool[] alreadyMatched = new bool[l2Count]; + for (int i = 0; i < l1Count; i++) { JToken o1 = l1[i]; bool gotmatch = false; @@ -105,7 +107,7 @@ public static bool DeepCompare(JToken v1, JToken v2, bool listOrderMatters) } else { - for (int j = 0; j < l2.Count; j++) + for (int j = 0; j < l2Count; j++) { if (!alreadyMatched[j] && DeepCompare(o1, l2[j], listOrderMatters)) {