Skip to content
This repository was archived by the owner on Apr 22, 2025. It is now read-only.

Commit 445221a

Browse files
Victor QuVictor Qu
authored andcommitted
OrderComparer
1 parent de9ac1e commit 445221a

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed
Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,20 @@
1-
namespace NZ.Orz.Routing;
1+
using System.Collections;
2+
3+
namespace NZ.Orz.Routing;
24

35
public class PriorityRouteDataList<T> : SortedDictionary<int, List<T>>
46
{
5-
public PriorityRouteDataList() : base(Comparer<int>.Default)
7+
public static readonly OrderComparer OrderComparer = new OrderComparer();
8+
9+
public PriorityRouteDataList() : base(OrderComparer)
10+
{
11+
}
12+
}
13+
14+
public class OrderComparer : IComparer<int>
15+
{
16+
public int Compare(int x, int y)
617
{
18+
return y.CompareTo(x);
719
}
820
}

src/NZ.Orz.Core/Routing/RouteTable.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public async ValueTask<T> MatchAsync<R>(string key, R data, Func<T, R, bool> mat
3636
{
3737
var all = await FindAllAsync(key);
3838
if (all.Length == 0) return default;
39-
foreach (var v in all)
39+
foreach (var v in all.AsSpan())
4040
{
4141
if (match(v, data))
4242
{

0 commit comments

Comments
 (0)