StringHash extensions renamed to Extensions

This commit is contained in:
vis2k 2021-02-16 17:40:26 +08:00
parent 092ce8b214
commit ffebaa9cc6
3 changed files with 22 additions and 18 deletions

View File

@ -0,0 +1,18 @@
namespace Mirror
{
public static class Extensions
{
// string.GetHashCode is not guaranteed to be the same on all machines, but
// we need one that is the same on all machines. simple and stupid:
public static int GetStableHashCode(this string text)
{
unchecked
{
int hash = 23;
foreach (char c in text)
hash = hash * 31 + c;
return hash;
}
}
}
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: decf32fd053744d18f35712b7a6f5116
timeCreated: 1613468378

View File

@ -1,18 +1 @@
namespace Mirror // removed 2021-02-16
{
public static class StringHash
{
// string.GetHashCode is not guaranteed to be the same on all machines, but
// we need one that is the same on all machines. simple and stupid:
public static int GetStableHashCode(this string text)
{
unchecked
{
int hash = 23;
foreach (char c in text)
hash = hash * 31 + c;
return hash;
}
}
}
}