diff --git a/benchmarks/Microsoft.AspNetCore.Routing.Performance/Matchers/AzureMatcherBenchmark.cs b/benchmarks/Microsoft.AspNetCore.Routing.Performance/Matchers/AzureMatcherBenchmark.cs index 2289e8352b..5a5d9f0a44 100644 --- a/benchmarks/Microsoft.AspNetCore.Routing.Performance/Matchers/AzureMatcherBenchmark.cs +++ b/benchmarks/Microsoft.AspNetCore.Routing.Performance/Matchers/AzureMatcherBenchmark.cs @@ -61,10 +61,6 @@ namespace Microsoft.AspNetCore.Routing.Matchers for (var i = 0; i < SampleCount; i++) { var sample = _samples[i]; - if (sample == 805) - { - GC.KeepAlive(5); - } var httpContext = _requests[sample]; await _dfa.MatchAsync(httpContext, feature); Validate(httpContext, _endpoints[sample], feature.Endpoint); diff --git a/benchmarks/Microsoft.AspNetCore.Routing.Performance/Matchers/GithubMatcherBenchmark.cs b/benchmarks/Microsoft.AspNetCore.Routing.Performance/Matchers/GithubMatcherBenchmark.cs index 251ee99ed8..39f2fb3c45 100644 --- a/benchmarks/Microsoft.AspNetCore.Routing.Performance/Matchers/GithubMatcherBenchmark.cs +++ b/benchmarks/Microsoft.AspNetCore.Routing.Performance/Matchers/GithubMatcherBenchmark.cs @@ -1,6 +1,7 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +using System; using System.Threading.Tasks; using BenchmarkDotNet.Attributes; diff --git a/test/Microsoft.AspNetCore.Routing.Tests/Matchers/InstructionMatcher.cs b/test/Microsoft.AspNetCore.Routing.Tests/Matchers/InstructionMatcher.cs index e6f31396c2..4920b8781a 100644 --- a/test/Microsoft.AspNetCore.Routing.Tests/Matchers/InstructionMatcher.cs +++ b/test/Microsoft.AspNetCore.Routing.Tests/Matchers/InstructionMatcher.cs @@ -63,7 +63,7 @@ namespace Microsoft.AspNetCore.Routing.Matchers } var i = 0; - Candidate match = default(Candidate); + var candidates = new List(); while (i < state.Instructions.Length) { var instruction = state.Instructions[i]; @@ -73,7 +73,7 @@ namespace Microsoft.AspNetCore.Routing.Matchers { if (count == instruction.Depth) { - match = state.Candidates[instruction.Payload]; + candidates.Add(state.Candidates[instruction.Payload]); } i++; break; @@ -92,10 +92,11 @@ namespace Microsoft.AspNetCore.Routing.Matchers } } - if (match.Endpoint != null) + var matches = new List<(Endpoint, RouteValueDictionary)>(); + for (i = 0; i < candidates.Count; i++) { var values = new RouteValueDictionary(); - var parameters = match.Parameters; + var parameters = candidates[i].Parameters; if (parameters != null) { for (var j = 0; j < parameters.Length; j++) @@ -113,13 +114,13 @@ namespace Microsoft.AspNetCore.Routing.Matchers } } - feature.Endpoint = match.Endpoint; - feature.Values = values; + matches.Add((candidates[i].Endpoint, values)); notmatch:; } - + feature.Endpoint = matches.Count == 0 ? null : matches[0].Item1; + feature.Values = matches.Count == 0 ? null : matches[0].Item2; return Task.CompletedTask; } diff --git a/test/Microsoft.AspNetCore.Routing.Tests/Matchers/InstructionMatcherBuilder.cs b/test/Microsoft.AspNetCore.Routing.Tests/Matchers/InstructionMatcherBuilder.cs index c736cd612e..40476d5008 100644 --- a/test/Microsoft.AspNetCore.Routing.Tests/Matchers/InstructionMatcherBuilder.cs +++ b/test/Microsoft.AspNetCore.Routing.Tests/Matchers/InstructionMatcherBuilder.cs @@ -35,7 +35,7 @@ namespace Microsoft.AspNetCore.Routing.Matchers return comparison; } - comparison = y.Precedence.CompareTo(x.Precedence); + comparison = x.Precedence.CompareTo(y.Precedence); if (comparison != 0) { return comparison;