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:
Yonik Seeley 2011-04-19 19:09:14 +00:00
parent 4a20fa5782
commit ccf84e155e
1 changed files with 4 additions and 2 deletions

View File

@ -186,9 +186,11 @@ public abstract class MultiLevelSkipListReader {
/** returns x == 0 ? 0 : Math.floor(Math.log(x) / Math.log(base)) */ /** returns x == 0 ? 0 : Math.floor(Math.log(x) / Math.log(base)) */
static int log(int x, int base) { static int log(int x, int base) {
assert base >= 2;
int ret = 0; int ret = 0;
while (x >= base) { long n = base; // needs to be a long to avoid overflow
x /= base; while (x >= n) {
n *= base;
ret++; ret++;
} }
return ret; return ret;