Permalink
Browse files

Stop type lookups on lexically bound symbols

This is a port of @ztellman's pending patch
http://dev.clojure.org/jira/browse/CLJ-1529

This patch avoids unnecessary lookups on symbols that are known to be
lexically bound, resulting in significant speedup in many cases. Details
are on the Jira page.
  • Loading branch information...
nasser committed Oct 3, 2014
1 parent ffbafe8 commit db1dabf57855cdc4524a8b35b07c20a7d481ca09
Showing with 6 additions and 1 deletion.
  1. +6 −1 Clojure/Clojure/CljCompiler/Ast/HostExpr.cs
@@ -281,6 +281,9 @@ public static Type MaybeType(object form, bool stringOk)
if (form is Symbol)
{
Symbol sym = (Symbol)form;
+ // if symbol refers to something in the lexical scope, it's not a type
+ if(Compiler.LocalEnvVar.deref() != null && ((IPersistentMap)Compiler.LocalEnvVar.deref()).containsKey(sym))
+ return null;
if (sym.Namespace == null) // if ns-qualified, can't be classname
{
if (Util.equals(sym, Compiler.CompileStubSymVar.get()))
@@ -317,7 +320,7 @@ public static Type MaybeType(object form, bool stringOk)
internal static Type TagToType(object tag)
{
- Type t = MaybeType(tag, true);
+ Type t = null;
Symbol sym = tag as Symbol;
if (sym != null)
@@ -395,6 +398,8 @@ internal static Type TagToType(object tag)
}
}
+ if(t == null)
+ t = MaybeType(tag, true);
if (t != null)
return t;

0 comments on commit db1dabf

Please sign in to comment.