Permalink
Browse files

Some performance enhancements by breaking out known binder types into…

… separate caches.
  • Loading branch information...
1 parent 6ac6e1a commit 2945c382d101851cda497567c491af71750343a5 @jbtule jbtule committed Oct 9, 2012
@@ -78,7 +78,7 @@ static Impromptu()
bool isEvent = false)
{
- return InvokeHelper.CreateCallSite(delegateType, binder.GetType(), () => binder, name, context, argNames,
+ return InvokeHelper.CreateCallSite(delegateType, binder.GetType(), InvokeHelper.Unknown, () => binder, name, context, argNames,
staticContext,
isEvent);
}
@@ -120,7 +120,7 @@ static Impromptu()
string[] argNames = null, bool staticContext = false,
bool isEvent = false) where T : class
{
- return InvokeHelper.CreateCallSite<T>(binder.GetType(), () => binder, name, context, argNames, staticContext,
+ return InvokeHelper.CreateCallSite<T>(binder.GetType(), InvokeHelper.Unknown, () => binder, name, context, argNames, staticContext,
isEvent);
}
@@ -22,9 +22,11 @@ namespace ImpromptuInterface.Optimization
{
internal class BinderHash
{
+
- protected BinderHash(Type delegateType, String_OR_InvokeMemberName name, Type context, string[] argNames, Type binderType, bool staticContext, bool isEvent)
+ protected BinderHash(Type delegateType, String_OR_InvokeMemberName name, Type context, string[] argNames, Type binderType, bool staticContext, bool isEvent, bool knownBinder)
{
+ KnownBinder = knownBinder;
BinderType = binderType;
StaticContext = staticContext;
DelegateType = delegateType;
@@ -35,12 +37,14 @@ protected BinderHash(Type delegateType, String_OR_InvokeMemberName name, Type co
}
- public static BinderHash Create(Type delType, String_OR_InvokeMemberName name, Type context, string[] argNames, Type binderType, bool staticContext, bool isEvent)
+
+
+ public static BinderHash Create(Type delType, String_OR_InvokeMemberName name, Type context, string[] argNames, Type binderType, bool staticContext, bool isEvent, bool knownBinder)
{
- return new BinderHash(delType, name, context, argNames, binderType, staticContext, isEvent);
+ return new BinderHash(delType, name, context, argNames, binderType, staticContext, isEvent, knownBinder);
}
-
+ public bool KnownBinder { get; protected set; }
public Type BinderType { get; protected set; }
public bool StaticContext { get; protected set; }
public bool IsEvent { get; protected set; }
@@ -62,7 +66,7 @@ public virtual bool Equals(BinderHash other)
&& other.IsEvent == IsEvent
&& other.StaticContext == StaticContext
&& Equals(other.Context, Context)
- && Equals(other.BinderType, BinderType)
+ && (KnownBinder || Equals(other.BinderType, BinderType))
&& Equals(other.DelegateType, DelegateType)
&& Equals(other.Name, Name)
&& (tArgNames == null
@@ -100,22 +104,22 @@ public override int GetHashCode()
internal class GenericBinderHashBase : BinderHash
{
- protected GenericBinderHashBase(Type delegateType, String_OR_InvokeMemberName name, Type context, string[] argNames, Type binderType, bool staticContext, bool isEvent)
- : base(delegateType, name, context, argNames, binderType, staticContext, isEvent)
+ protected GenericBinderHashBase(Type delegateType, String_OR_InvokeMemberName name, Type context, string[] argNames, Type binderType, bool staticContext, bool isEvent, bool knownBinder)
+ : base(delegateType, name, context, argNames, binderType, staticContext, isEvent, knownBinder)
{
}
}
internal class BinderHash<T> : GenericBinderHashBase where T : class
{
- public static BinderHash<T> Create(String_OR_InvokeMemberName name, Type context, string[] argNames, Type binderType, bool staticContext, bool isEvent)
+ public static BinderHash<T> Create(String_OR_InvokeMemberName name, Type context, string[] argNames, Type binderType, bool staticContext, bool isEvent, bool knownBinder)
{
- return new BinderHash<T>(name, context, argNames, binderType, staticContext, isEvent );
+ return new BinderHash<T>(name, context, argNames, binderType, staticContext, isEvent, knownBinder);
}
- protected BinderHash(String_OR_InvokeMemberName name, Type context, string[] argNames, Type binderType, bool staticContext, bool isEvent)
- : base(typeof(T), name, context, argNames, binderType, staticContext, isEvent)
+ protected BinderHash(String_OR_InvokeMemberName name, Type context, string[] argNames, Type binderType, bool staticContext, bool isEvent,bool knownBinder)
+ : base(typeof(T), name, context, argNames, binderType, staticContext, isEvent,knownBinder)
{
}
@@ -130,7 +134,7 @@ public override bool Equals(BinderHash other)
!(other.ArgNames == null ^ ArgNames == null)
&& other.IsEvent == IsEvent
&& other.StaticContext == StaticContext
- && Equals(other.BinderType, BinderType)
+ && (KnownBinder || Equals(other.BinderType, BinderType))
&& Equals(other.Context, Context)
&& Equals(other.Name, Name)
&& (ArgNames == null
Oops, something went wrong.

0 comments on commit 2945c38

Please sign in to comment.