2
0
Эх сурвалжийг харах

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
Thaddeus Crews 5 сар өмнө
parent
commit
561dc6ced6

+ 10 - 0
modules/mono/glue/GodotSharp/GodotSharp/Core/Bridge/CSharpInstanceBridge.cs

@@ -59,6 +59,11 @@ namespace Godot.Bridge
                     return godot_bool.True;
                     return godot_bool.True;
                 }
                 }
 
 
+                if (!godotObject.HasGodotClassMethod(GodotObject.MethodName._Set.NativeValue.DangerousSelfRef))
+                {
+                    return godot_bool.False;
+                }
+
                 var nameManaged = StringName.CreateTakingOwnershipOfDisposableValue(
                 var nameManaged = StringName.CreateTakingOwnershipOfDisposableValue(
                     NativeFuncs.godotsharp_string_name_new_copy(CustomUnsafe.AsRef(name)));
                     NativeFuncs.godotsharp_string_name_new_copy(CustomUnsafe.AsRef(name)));
 
 
@@ -107,6 +112,11 @@ namespace Godot.Bridge
                     return godot_bool.True;
                     return godot_bool.True;
                 }
                 }
 
 
+                if (!godotObject.HasGodotClassMethod(GodotObject.MethodName._Get.NativeValue.DangerousSelfRef))
+                {
+                    return godot_bool.False;
+                }
+
                 var nameManaged = StringName.CreateTakingOwnershipOfDisposableValue(
                 var nameManaged = StringName.CreateTakingOwnershipOfDisposableValue(
                     NativeFuncs.godotsharp_string_name_new_copy(CustomUnsafe.AsRef(name)));
                     NativeFuncs.godotsharp_string_name_new_copy(CustomUnsafe.AsRef(name)));