From 27e1401fc7452b61e92f815c11d5e1097af05c93 Mon Sep 17 00:00:00 2001 From: Ari Vuollet Date: Sun, 13 Aug 2023 14:24:48 +0300 Subject: [PATCH] Slightly improve `MClass::GetMethod` method iteration Check the number of parameters first before expensive string comparison --- Source/Engine/Scripting/Runtime/DotNet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Engine/Scripting/Runtime/DotNet.cpp b/Source/Engine/Scripting/Runtime/DotNet.cpp index 36f1f16af..f4ae5b1ec 100644 --- a/Source/Engine/Scripting/Runtime/DotNet.cpp +++ b/Source/Engine/Scripting/Runtime/DotNet.cpp @@ -878,7 +878,7 @@ MMethod* MClass::GetMethod(const char* name, int32 numParams) const GetMethods(); for (int32 i = 0; i < _methods.Count(); i++) { - if (_methods[i]->GetName() == name && _methods[i]->GetParametersCount() == numParams) + if (_methods[i]->GetParametersCount() == numParams && _methods[i]->GetName() == name) return _methods[i]; } return nullptr;