feat:support for concurrent file-based queries

This commit is contained in:
Alan
2023-07-26 21:25:34 +08:00
parent c8446edaab
commit 7f5ec337d0
13 changed files with 259 additions and 143 deletions

View File

@@ -1,4 +1,5 @@
using System.Net;
using System.Runtime.InteropServices;
namespace IP2Region.Net.XDB;
@@ -14,12 +15,9 @@ public static class Util
{
byte[] bytes = ipAddress.GetAddressBytes();
Array.Reverse(bytes);
return BitConverter.ToUInt32(bytes, 0);
return MemoryMarshal.Read<uint>(bytes);
}
public static uint GetMidIp(uint x, uint y)
=> (x & y) + ((x ^ y) >> 1);
public static int GetMidIp(int x, int y)
=> (x & y) + ((x ^ y) >> 1);
}