提交 56a3ab02 authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov

Use do-while loop in higherKey() and lowerKey()

上级 6bb90ad6
...@@ -1339,13 +1339,10 @@ public class TransactionStore { ...@@ -1339,13 +1339,10 @@ public class TransactionStore {
* @return the result * @return the result
*/ */
public K higherKey(K key) { public K higherKey(K key) {
while (true) { do {
K k = map.higherKey(key); key = map.higherKey(key);
if (k == null || get(k) != null) { } while (key != null && get(key) == null);
return k; return key;
}
key = k;
}
} }
/** /**
...@@ -1373,13 +1370,10 @@ public class TransactionStore { ...@@ -1373,13 +1370,10 @@ public class TransactionStore {
* @return the result * @return the result
*/ */
public K lowerKey(K key) { public K lowerKey(K key) {
while (true) { do {
K k = map.lowerKey(key); key = map.lowerKey(key);
if (k == null || get(k) != null) { } while (key != null && get(key) == null);
return k; return key;
}
key = k;
}
} }
/** /**
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论