ICU-13246 Save a few cycles by performing util64_pow multiply only when needed.
X-SVN-Rev: 40285
This commit is contained in:
parent
d847a21238
commit
112d214d29
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user