ICU-12462 Slightly improve the power function performance.

X-SVN-Rev: 39161
This commit is contained in:
George Rhoten 2016-09-08 18:35:21 +00:00
parent 4bd854a73c
commit 08c37f83f0

View file

@ -838,13 +838,12 @@ final class NFRule {
throw new IllegalArgumentException("Base can not be negative");
}
long result = 1;
long pow = base;
while (exponent > 0) {
if ((exponent & 1) == 1) {
result *= pow;
result *= base;
}
pow *= pow;
exponent = (short) (exponent >> 1);
base *= base;
exponent >>= 1;
}
return result;
}