Fix C# string.Hash()

(cherry picked from commit baac70c27e)
This commit is contained in:
zaevi 2021-01-31 20:39:17 +08:00 committed by Rémi Verschelde
parent c10c6cfad9
commit f94dffd2de
No known key found for this signature in database
GPG Key ID: C3336907360768E1
1 changed files with 8 additions and 8 deletions

View File

@ -470,18 +470,18 @@ namespace Godot
}
// <summary>
// Hash the string and return a 32 bits integer.
// Hash the string and return a 32 bits unsigned integer.
// </summary>
public static int Hash(this string instance)
public static uint Hash(this string instance)
{
int index = 0;
int hashv = 5381;
int c;
uint hash = 5381;
while ((c = instance[index++]) != 0)
hashv = (hashv << 5) + hashv + c; // hash * 33 + c
foreach(uint c in instance)
{
hash = (hash << 5) + hash + c; // hash * 33 + c
}
return hashv;
return hash;
}
/// <summary>