diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2021-02-01 11:32:58 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-01 11:32:58 +0100 |
commit | c691444d2e63c95fdfb9501e5080387cbc8737f2 (patch) | |
tree | 7153bc7d47d640c9ebe2560216b0cc1a6c991234 /modules/mono/glue/GodotSharp | |
parent | d811f8610223ebceb4796fa82d770c33db1fab6f (diff) | |
parent | baac70c27efb661e2d3f4127210e7ec991793078 (diff) |
Merge pull request #45603 from zaevi/csharp_fix_string_hash
[C#] Fix string.Hash()
Diffstat (limited to 'modules/mono/glue/GodotSharp')
-rw-r--r-- | modules/mono/glue/GodotSharp/GodotSharp/Core/StringExtensions.cs | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/StringExtensions.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/StringExtensions.cs index 4dc182fb73..98efa89ef0 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/StringExtensions.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/StringExtensions.cs @@ -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> |