From 69aada932067bf4b1ba21fe360fe7475aa96df36 Mon Sep 17 00:00:00 2001 From: jfrijters Date: Wed, 19 Sep 2007 09:38:05 +0000 Subject: [PATCH] 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(). --- runtime/TypeWrapper.cs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/runtime/TypeWrapper.cs b/runtime/TypeWrapper.cs index e00ee653..ee2c8a1d 100644 --- a/runtime/TypeWrapper.cs +++ b/runtime/TypeWrapper.cs @@ -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; } }