[runtime] Optimize mono_class_field_is_special_static () a bit.
authorAlex Rønne Petersen <alexrp@xamarin.com>
Thu, 3 Sep 2015 22:30:46 +0000 (00:30 +0200)
committerAlex Rønne Petersen <alexrp@xamarin.com>
Thu, 3 Sep 2015 22:34:38 +0000 (00:34 +0200)
We can avoid loading custom attributes by checking field->offset == -1. This
won't always be the case for a special static field at all stages during class
loading but it'll speed up the most frequent cases.

mono/metadata/object.c

index 7604585dcadebda52d74e5f561295e6373758d6e..31746e2308d5456ba833573d8af534c65edf838d 100644 (file)
@@ -2419,6 +2419,8 @@ mono_class_field_is_special_static (MonoClassField *field)
        if (mono_field_is_deleted (field))
                return FALSE;
        if (!(field->type->attrs & FIELD_ATTRIBUTE_LITERAL)) {
+               if (field->offset == -1)
+                       return TRUE;
                if (field_is_special_static (field->parent, field) != SPECIAL_STATIC_NONE)
                        return TRUE;
        }