fix(core): Fixes type caching & cleanup (#422)

- [X] Fixes some issues with the type caching
- [X] Changes type check default to ignore case
- [X] Splits out type caching of insensitive and sensitive lists. This means less stuff to iterate through when checking a type against the string.
- [X] Adds an ArrayEnumerator, mostly for reference purposes (copy/paste as needed)
This commit is contained in:
Kamron Batman 2021-01-20 00:10:33 -08:00 • committed by GitHub
parent b921c38879
commit e869c105d0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
35 changed files with 253 additions and 96 deletions

View file

@ -2,6 +2,7 @@ using System;
using System.Collections.Generic;
using System.IO;
using System.Net;
using System.Runtime.CompilerServices;
using Microsoft.Toolkit.HighPerformance.Extensions;
namespace Server
@ -155,6 +156,7 @@ namespace Server
};
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public override int GetHashCode() => m_Address.GetHashCode();
}
@ -198,7 +200,8 @@ namespace Server
return false;
}
public override int GetHashCode() => m_CIDRPrefix.GetHashCode() ^ m_CIDRLength.GetHashCode();
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public override int GetHashCode() => HashCode.Combine(m_CIDRPrefix, m_CIDRLength);
}
public class WildcardIPFirewallEntry : IFirewallEntry
@ -223,6 +226,7 @@ namespace Server
return obj is WildcardIPFirewallEntry entry && m_Entry == entry.m_Entry;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public override int GetHashCode() => m_Entry.GetHashCode(StringComparison.Ordinal);
}
}