From 54ee9efcdfe8a2799b2fb718cfa7b88a91700229 Mon Sep 17 00:00:00 2001 From: Oscar Smith Date: Wed, 14 Sep 2022 12:27:14 -0400 Subject: [PATCH] speed up Ryu.pow5 --- base/ryu/utils.jl | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/base/ryu/utils.jl b/base/ryu/utils.jl index 352f8f19cb9be..af1354bf851f3 100644 --- a/base/ryu/utils.jl +++ b/base/ryu/utils.jl @@ -65,14 +65,7 @@ lengthforindex(idx) = div(((Int64(16 * idx) * 1292913986) >> 32) + 1 + 16 + 8, 9 Return `true` if `5^p` is a divisor of `x`. """ @inline function pow5(x, p) - count = 0 - while true - q = div(x, 5) - r = x - 5 * q - r != 0 && return count >= p - x = q - count += 1 - end + x % (5^p) == 0 end """