--- jsr166/src/jsr166e/ConcurrentHashMapV8.java 2012/11/23 17:50:51 1.79 +++ jsr166/src/jsr166e/ConcurrentHashMapV8.java 2012/12/08 14:10:38 1.81 @@ -867,16 +867,17 @@ public class ConcurrentHashMapV8 if (c != (pc = pk.getClass()) || !(k instanceof Comparable) || (dir = ((Comparable)k).compareTo((Comparable)pk)) == 0) { - dir = (c == pc) ? 0 : c.getName().compareTo(pc.getName()); - TreeNode r = null, s = null, pl, pr; - if (dir >= 0) { - if ((pl = p.left) != null && h <= pl.hash) - s = pl; + if ((dir = (c == pc) ? 0 : + c.getName().compareTo(pc.getName())) == 0) { + TreeNode r = null, pl, pr; // check both sides + if ((pr = p.right) != null && h >= pr.hash && + (r = getTreeNode(h, k, pr)) != null) + return r; + else if ((pl = p.left) != null && h <= pl.hash) + dir = -1; + else // nothing there + return null; } - else if ((pr = p.right) != null && h >= pr.hash) - s = pr; - if (s != null && (r = getTreeNode(h, k, s)) != null) - return r; } } else @@ -931,11 +932,14 @@ public class ConcurrentHashMapV8 if (c != (pc = pk.getClass()) || !(k instanceof Comparable) || (dir = ((Comparable)k).compareTo((Comparable)pk)) == 0) { - dir = (c == pc) ? 0 : c.getName().compareTo(pc.getName()); - TreeNode r = null, s = null, pl, pr; - if (dir >= 0) { - if ((pl = p.left) != null && h <= pl.hash) - s = pl; + TreeNode s = null, r = null, pr; + if ((dir = (c == pc) ? 0 : + c.getName().compareTo(pc.getName())) == 0) { + if ((pr = p.right) != null && h >= pr.hash && + (r = getTreeNode(h, k, pr)) != null) + return r; + else // continue left + dir = -1; } else if ((pr = p.right) != null && h >= pr.hash) s = pr; @@ -2523,7 +2527,7 @@ public class ConcurrentHashMapV8 b = (n <= 0L) ? 0 : (n < (long)sp) ? (int)n : sp; } } - b = (b <= 1 || baseIndex == baseLimit)? 0 : (b >>> 1); + b = (b <= 1 || baseIndex == baseLimit) ? 0 : (b >>> 1); if ((batch = b) > 0) addToPendingCount(1); return b;