X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=src%2Forg%2Fibex%2FIbex.java;h=d1e328414e36f8266a27e3d8b3484e52d0cd3ce0;hb=2532e32f07910e63b366ac8e02e897e5314be72c;hp=61b51a8098eef4addea2158f953d32d5785afa6a;hpb=2bd54cd76cc8c8f82170549af93e089a7a724cc6;p=org.ibex.core.git diff --git a/src/org/ibex/Ibex.java b/src/org/ibex/Ibex.java index 61b51a8..d1e3284 100644 --- a/src/org/ibex/Ibex.java +++ b/src/org/ibex/Ibex.java @@ -329,10 +329,15 @@ public final class Ibex extends JS.Cloneable { private Template t = null; public Object parentkey = null; public Blessing parent = null; + private Hash cache = new Hash(); public Blessing(JS.Cloneable clonee, Ibex ibex, Blessing parent, Object parentkey) { super(clonee); this.ibex = ibex; this.parentkey = parentkey; this.parent = parent; } public Object get(Object key) throws JSExn { - return key.equals("") ? ((Object)getStatic()) : (new Blessing((JS.Cloneable)clonee.get(key), ibex, this, key)); + if (key.equals("")) return ((Object)getStatic()); + if (cache.get(key) != null) return cache.get(key); + Object ret = new Blessing((JS.Cloneable)clonee.get(key), ibex, this, key); + cache.put(key, ret); + return ret; } public static Blessing getBlessing(Object o) { if (!(o instanceof JS)) return null; @@ -356,9 +361,7 @@ public final class Ibex extends JS.Cloneable { } public JSScope getStatic() { try { - // FIXME background? - if (t == null) - t = Template.buildTemplate(parentkey + ".t", parent.get(parentkey + ".t"), ibex); + if (t == null) t = Template.buildTemplate(parentkey + ".t", parent.get(parentkey + ".t"), ibex); return t.staticScope; } catch (Exception e) { Log.error(this, e);