X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;ds=sidebyside;f=src%2Forg%2Fxwt%2FRes.java;h=b9569315257c8925d7c380a0edc76fac0c850fbb;hb=38786988d12f2c48a314ee37c326965ff0bcadb6;hp=8f7906a7bfa54a511043e930e32d12dc8268d624;hpb=54804921e2d7ed0fe98d92e7dfe962aec95a64b4;p=org.ibex.core.git diff --git a/src/org/xwt/Res.java b/src/org/xwt/Res.java index 8f7906a..b956931 100644 --- a/src/org/xwt/Res.java +++ b/src/org/xwt/Res.java @@ -14,7 +14,17 @@ public abstract class Res extends JS { public final InputStream getInputStream() throws IOException { return getInputStream(""); } public Res graft(Object newResource) { throw new JS.Exn("cannot graft onto this resource"); } - public Object get(Object key) { return new Ref(this, key); } + + private Hash refCache = null; + public Object get(Object key) { + Object ret = refCache == null ? null : refCache.get(key); + if (ret != null) return ret; + ret = new Ref(this, key); + if (refCache == null) refCache = new Hash(); + refCache.put(key, ret); + return ret; + } + public void put(Object key, Object val) { throw new JS.Exn("cannot put to a resource"); } public Object[] keys() { throw new JS.Exn("cannot enumerate a resource"); }