internal BinOpCacheEntry(Type key1,Type key2,Object val,BinOpCacheEntry next) { this.key1 = key1; this.key2 = key2; this.val = val; this.next = next; }
internal BinOpCacheEntry(Type key1, Type key2, Object val, BinOpCacheEntry next) { this.key1 = key1; this.key2 = key2; this.val = val; this.next = next; }
Object findCachedMethod(Type t1, Type t2) { BinOpCacheEntry entry = findCacheEntry(t1, t2); if (entry != null) { return(entry.val); } return(null); }
void cacheMethod(Type t1, Type t2, Object method) { //if can find an existing entry, swap the value BinOpCacheEntry e = findCacheEntry(t1, t2); if (e == null) { cache = new BinOpCacheEntry(t1, t2, method, cache); } else { e.val = method; } }
BinOpCacheEntry findCacheEntry(Type t1, Type t2) { for (BinOpCacheEntry e = cache; e != null; e = e.next) //for(BinOpCacheEntry e = cache,prev = null;e!=null;prev = e,e = e.next) { if (e.key1 == t1 && e.key2 == t2) { //this linked-list method could be a problem with threads //move to top of list if found //if(prev != null) // { // prev.next = e.next; // e.next = cache; // cache = e; // } return(e); } } return(null); }
void clearCache() { //methodCache.Clear(); cache = null; }
void cacheMethod(Type t1,Type t2,Object method) { //if can find an existing entry, swap the value BinOpCacheEntry e = findCacheEntry(t1,t2); if(e == null) cache = new BinOpCacheEntry(t1,t2,method,cache); else e.val = method; }