mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 02:50:32 +00:00
StringHash extensions renamed to Extensions
This commit is contained in:
parent
092ce8b214
commit
ffebaa9cc6
18
Assets/Mirror/Runtime/Extensions.cs
Normal file
18
Assets/Mirror/Runtime/Extensions.cs
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
3
Assets/Mirror/Runtime/Extensions.cs.meta
Normal file
3
Assets/Mirror/Runtime/Extensions.cs.meta
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: decf32fd053744d18f35712b7a6f5116
|
||||||
|
timeCreated: 1613468378
|
@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user