Skip to content

Commit 561dc6c

Browse files
committed
Merge pull request #104689 from Delsin-Yu/csharp-getset-alloc-perf
[.Net] Avoid unnecessary StringName allocations on not implemented virtual _Get and _Set method call
2 parents e1509d5 + f0ec392 commit 561dc6c

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

modules/mono/glue/GodotSharp/GodotSharp/Core/Bridge/CSharpInstanceBridge.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,11 @@ internal static unsafe godot_bool Set(IntPtr godotObjectGCHandle, godot_string_n
5959
return godot_bool.True;
6060
}
6161

62+
if (!godotObject.HasGodotClassMethod(GodotObject.MethodName._Set.NativeValue.DangerousSelfRef))
63+
{
64+
return godot_bool.False;
65+
}
66+
6267
var nameManaged = StringName.CreateTakingOwnershipOfDisposableValue(
6368
NativeFuncs.godotsharp_string_name_new_copy(CustomUnsafe.AsRef(name)));
6469

@@ -107,6 +112,11 @@ internal static unsafe godot_bool Get(IntPtr godotObjectGCHandle, godot_string_n
107112
return godot_bool.True;
108113
}
109114

115+
if (!godotObject.HasGodotClassMethod(GodotObject.MethodName._Get.NativeValue.DangerousSelfRef))
116+
{
117+
return godot_bool.False;
118+
}
119+
110120
var nameManaged = StringName.CreateTakingOwnershipOfDisposableValue(
111121
NativeFuncs.godotsharp_string_name_new_copy(CustomUnsafe.AsRef(name)));
112122

0 commit comments

Comments
 (0)