فهرست منبع

[.NET] Avoid heap allocation when using StringNames as key in a Collection.Dictionary.

Changed StringName GetHashCode to call godot_string_name.GetHashCode instead of godot_string_name's (which was not overridden) as this otherwise leads to heap allocations when e.g. calling the indexer in a Dictionary with `StringName` type as Key.
Fredrik Lindahl 4 ماه پیش
والد
کامیت
01056f369a
1فایلهای تغییر یافته به همراه1 افزوده شده و 1 حذف شده
  1. 1 1
      modules/mono/glue/GodotSharp/GodotSharp/Core/StringName.cs

+ 1 - 1
modules/mono/glue/GodotSharp/GodotSharp/Core/StringName.cs

@@ -161,7 +161,7 @@ namespace Godot
 
         public override int GetHashCode()
         {
-            return NativeValue.GetHashCode();
+            return NativeValue.DangerousSelfRef.GetHashCode();
         }
     }
 }