From 6266b3b5b7d3d3e28ce90a56af6e52a94f305a76 Mon Sep 17 00:00:00 2001 From: hns Date: Wed, 30 Oct 2002 11:46:51 +0000 Subject: [PATCH] Always rotate tables if new table exceeds threshold. --- src/helma/util/CacheMap.java | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/helma/util/CacheMap.java b/src/helma/util/CacheMap.java index 10d4b077..7816f9fe 100644 --- a/src/helma/util/CacheMap.java +++ b/src/helma/util/CacheMap.java @@ -231,14 +231,15 @@ public class CacheMap { oldValue = oldTable.get (key); if (oldValue != null) oldTable.remove( key ); - else { - if (newTable.size() >= threshold) { - // Rotate the tables. - if (logger != null) - logger.log ("Rotating Cache tables at "+newTable.size()+"/"+oldTable.size()+" (new/old)"); - oldTable = newTable; - newTable = new HashMap (eachCapacity, loadFactor); - } + // we put a key into newtable that wasn't there before. check if it + // grew beyond the threshold + if (newTable.size() >= threshold) { + // Rotate the tables. + if (logger != null) + logger.log ("Rotating Cache tables at "+newTable.size()+ + "/"+oldTable.size()+" (new/old)"); + oldTable = newTable; + newTable = new HashMap (eachCapacity, loadFactor); } return oldValue; }