Fixed performance issue in scripts editor when multiple attributes are applied onto script fields

This commit is contained in:
Kah Wei 2022-11-09 10:31:30 +08:00
parent 349f4a875b
commit a3fe98317d
1 changed files with 3 additions and 12 deletions

View File

@ -414,19 +414,10 @@ namespace SHADE
generic<typename Attribute> generic<typename Attribute>
Attribute Editor::hasAttribute(System::Reflection::FieldInfo^ field) Attribute Editor::hasAttribute(System::Reflection::FieldInfo^ field)
{ {
array<System::Object^>^ attributes = field->GetCustomAttributes(true); array<System::Object^>^ attributes = field->GetCustomAttributes(Attribute::typeid, false);
for each (System::Object^ attrib in attributes) if (attributes->Length > 0)
{ {
try return safe_cast<Attribute>(attributes[0]);
{
Attribute attribute = safe_cast<Attribute>(attrib);
if (attribute != nullptr)
return attribute;
}
catch (System::InvalidCastException^)
{
continue;
}
} }
// Failed to find // Failed to find
return Attribute{}; return Attribute{};