From a3fe98317dc4be18cbfa0b035062b75ac8abef38 Mon Sep 17 00:00:00 2001 From: Kah Wei Date: Wed, 9 Nov 2022 10:31:30 +0800 Subject: [PATCH] Fixed performance issue in scripts editor when multiple attributes are applied onto script fields --- SHADE_Managed/src/Editor/Editor.cxx | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/SHADE_Managed/src/Editor/Editor.cxx b/SHADE_Managed/src/Editor/Editor.cxx index 2afe9697..54200c1e 100644 --- a/SHADE_Managed/src/Editor/Editor.cxx +++ b/SHADE_Managed/src/Editor/Editor.cxx @@ -414,19 +414,10 @@ namespace SHADE generic Attribute Editor::hasAttribute(System::Reflection::FieldInfo^ field) { - array^ attributes = field->GetCustomAttributes(true); - for each (System::Object^ attrib in attributes) + array^ attributes = field->GetCustomAttributes(Attribute::typeid, false); + if (attributes->Length > 0) { - try - { - Attribute attribute = safe_cast(attrib); - if (attribute != nullptr) - return attribute; - } - catch (System::InvalidCastException^) - { - continue; - } + return safe_cast(attributes[0]); } // Failed to find return Attribute{};