Merge pull request #45603 from zaevi/csharp_fix_string_hash

[C#] Fix string.Hash()
This commit is contained in:
Rémi Verschelde 2021-02-01 11:32:58 +01:00 committed by GitHub
commit c691444d2e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -462,18 +462,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>