lib/encoding: substitute 64-bits.LeadingZeros64() with bits.Len64()

This commit is contained in:
Aliaksandr Valialkin 2022-01-31 23:36:48 +02:00
parent a8509c112a
commit e13ce2ee98
No known key found for this signature in database
GPG Key ID: A72BEC6CD3D0DED1

View File

@ -93,7 +93,7 @@ func nearestDelta(next, prev int64, precisionBits, prevTrailingZeros uint8) (int
// There is no need in handling special case origin = -1<<63.
}
originBits := 64 - uint8(bits.LeadingZeros64(uint64(origin)))
originBits := uint8(bits.Len64(uint64(origin)))
if originBits <= precisionBits {
// Cannot zero trailing bits for the given precisionBits.
return d, decIfNonZero(prevTrailingZeros)
@ -136,7 +136,7 @@ func getTrailingZeros(v int64, precisionBits uint8) uint8 {
v = -v
// There is no need in special case handling for v = -1<<63
}
vBits := 64 - uint8(bits.LeadingZeros64(uint64(v)))
vBits := uint8(bits.Len64(uint64(v)))
if vBits <= precisionBits {
return 0
}