Skip to content

Commit

Permalink
minor optimization for PowerOfTwo functions
Browse files Browse the repository at this point in the history
  • Loading branch information
abi87 committed Oct 16, 2024
1 parent 8c2030a commit 2806185
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions mod/primitives/pkg/math/pow/pow.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ package pow
//
//nolint:mnd // todo fix.
func PrevPowerOfTwo[U64T ~uint64](u U64T) U64T {
if u == 0 {
if u <= 1 {
return 1
}
u |= u >> 1
Expand All @@ -40,7 +40,7 @@ func PrevPowerOfTwo[U64T ~uint64](u U64T) U64T {
//
//nolint:mnd // todo fix.
func NextPowerOfTwo[U64T ~uint64](u U64T) U64T {
if u == 0 {
if u <= 1 {
return 1
}
if u > 1<<63 {
Expand Down

0 comments on commit 2806185

Please sign in to comment.