mirror of
https://github.com/godotengine/godot.git
synced 2025-04-25 01:48:08 +08:00
Fix C# string.Hash()
(cherry picked from commit baac70c27efb661e2d3f4127210e7ec991793078)
This commit is contained in:
parent
c10c6cfad9
commit
f94dffd2de
@ -470,18 +470,18 @@ namespace Godot
|
|||||||
}
|
}
|
||||||
|
|
||||||
// <summary>
|
// <summary>
|
||||||
// Hash the string and return a 32 bits integer.
|
// Hash the string and return a 32 bits unsigned integer.
|
||||||
// </summary>
|
// </summary>
|
||||||
public static int Hash(this string instance)
|
public static uint Hash(this string instance)
|
||||||
{
|
{
|
||||||
int index = 0;
|
uint hash = 5381;
|
||||||
int hashv = 5381;
|
|
||||||
int c;
|
|
||||||
|
|
||||||
while ((c = instance[index++]) != 0)
|
foreach(uint c in instance)
|
||||||
hashv = (hashv << 5) + hashv + c; // hash * 33 + c
|
{
|
||||||
|
hash = (hash << 5) + hash + c; // hash * 33 + c
|
||||||
|
}
|
||||||
|
|
||||||
return hashv;
|
return hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user