Cache ReflectiveModifiers in CompiledTypeWrapper. AttributeHelper.GetInnerClass() is expensive and this property is called directly in response to Class.getModifiers(), so caching the modifiers results in a significant speedup of Class.getModifiers() which in turns speeds up Constructor.newInstance().

This commit is contained in:
jfrijters 2007-09-19 09:38:05 +00:00
Родитель 220166a19e
Коммит 69aada9320
1 изменённых файлов: 12 добавлений и 4 удалений

Просмотреть файл

@ -7837,6 +7837,7 @@ namespace IKVM.Internal
private TypeWrapper[] interfaces;
private TypeWrapper[] innerclasses;
private MethodInfo clinitMethod;
private Modifiers reflectiveModifiers;
internal static CompiledTypeWrapper newInstance(string name, Type type)
{
@ -8213,12 +8214,19 @@ namespace IKVM.Internal
{
get
{
InnerClassAttribute attr = AttributeHelper.GetInnerClass(type);
if(attr != null)
if (reflectiveModifiers == 0)
{
return attr.Modifiers;
InnerClassAttribute attr = AttributeHelper.GetInnerClass(type);
if (attr != null)
{
reflectiveModifiers = attr.Modifiers;
}
else
{
reflectiveModifiers = Modifiers;
}
}
return Modifiers;
return reflectiveModifiers;
}
}