Skip to content

Commit 01056f3

Browse files
committed
[.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.
1 parent 6a6a116 commit 01056f3

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

modules/mono/glue/GodotSharp/GodotSharp/Core/StringName.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ public override bool Equals([NotNullWhen(true)] object? obj)
161161

162162
public override int GetHashCode()
163163
{
164-
return NativeValue.GetHashCode();
164+
return NativeValue.DangerousSelfRef.GetHashCode();
165165
}
166166
}
167167
}

0 commit comments

Comments
 (0)