--- jsr166/src/jsr166e/ConcurrentHashMapV8.java 2012/11/24 03:46:28 1.80 +++ 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;