ICU-13246 Save a few cycles by performing util64_pow multiply only when needed.

X-SVN-Rev: 40285
This commit is contained in:
Shane Carr 2017-07-24 22:00:22 +00:00
parent d847a21238
commit 112d214d29

View File

@ -836,12 +836,15 @@ uint64_t util64_pow(uint32_t base, uint16_t exponent) {
}
uint64_t result = 1;
uint64_t pow = base;
while (exponent > 0) {
while (true) {
if ((exponent & 1) == 1) {
result *= pow;
}
pow *= pow;
exponent >>= 1;
if (exponent == 0) {
break;
}
pow *= pow;
}
return result;
}