mirror of
https://github.com/golang/go.git
synced 2025-10-19 11:03:18 +00:00
cmd/compile: simplify isUintXPowerOfTwo implementation
By calling isUnsignedPowerOfTwo instead of duplicating the same ones. Change-Id: I1e29d3b7eda1bc8773fcd25728d8f508ae633ac9 Reviewed-on: https://go-review.googlesource.com/c/go/+/692916 Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Keith Randall <khr@google.com> Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
This commit is contained in:
parent
26da1199eb
commit
72147ffa75
1 changed files with 2 additions and 8 deletions
|
@ -505,16 +505,10 @@ func isUnsignedPowerOfTwo[T uint8 | uint16 | uint32 | uint64](n T) bool {
|
|||
}
|
||||
|
||||
// isUint64PowerOfTwo reports whether uint64(n) is a power of 2.
|
||||
func isUint64PowerOfTwo(in int64) bool {
|
||||
n := uint64(in)
|
||||
return n != 0 && n&(n-1) == 0
|
||||
}
|
||||
func isUint64PowerOfTwo(in int64) bool { return isUnsignedPowerOfTwo(uint64(in)) }
|
||||
|
||||
// isUint32PowerOfTwo reports whether uint32(n) is a power of 2.
|
||||
func isUint32PowerOfTwo(in int64) bool {
|
||||
n := uint64(uint32(in))
|
||||
return n != 0 && n&(n-1) == 0
|
||||
}
|
||||
func isUint32PowerOfTwo(in int64) bool { return isUnsignedPowerOfTwo(uint32(in)) }
|
||||
|
||||
// is32Bit reports whether n can be represented as a signed 32 bit integer.
|
||||
func is32Bit(n int64) bool {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue