mirror of https://github.com/apache/lucene.git
LUCENE-3037: replace idiv with imul in log
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1095169 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
4a20fa5782
commit
ccf84e155e
|
@ -186,9 +186,11 @@ public abstract class MultiLevelSkipListReader {
|
|||
|
||||
/** returns x == 0 ? 0 : Math.floor(Math.log(x) / Math.log(base)) */
|
||||
static int log(int x, int base) {
|
||||
assert base >= 2;
|
||||
int ret = 0;
|
||||
while (x >= base) {
|
||||
x /= base;
|
||||
long n = base; // needs to be a long to avoid overflow
|
||||
while (x >= n) {
|
||||
n *= base;
|
||||
ret++;
|
||||
}
|
||||
return ret;
|
||||
|
|
Loading…
Reference in New Issue