]> Cypherpunks repositories - gostls13.git/commit
cmd/internal/obj/arm64, image/gif, runtime, sort: use math/bits to calculate log2
authorAxel Wagner <axel.wagner.hh@googlemail.com>
Wed, 19 Nov 2025 08:28:16 +0000 (09:28 +0100)
committerSean Liao <sean@liao.dev>
Sun, 23 Nov 2025 11:49:34 +0000 (03:49 -0800)
commita18294bb6aa8f0dd656f2bcb6742f9de2936d0dc
tree7d9c0dfc5cfbfe4968c6edfaf6b955e06cbb12e9
parent437323ef7b933255c5c7fbb0775019e95f19b05e
cmd/internal/obj/arm64, image/gif, runtime, sort: use math/bits to calculate log2

In several places the integer log2 is calculated using loops or similar
mechanisms. math/bits.Len* provide a simpler and more efficient
mechanisms for this.

Annoyingly, every usage has slightly different ideas of what "log2"
means and how non-positive inputs should be handled. I verified the
replacements in each case by comparing the result for inputs from 0
to 1<<16.

Change-Id: Ie962a74674802da363e0038d34c06979ccb41cf3
Reviewed-on: https://go-review.googlesource.com/c/go/+/721880
Reviewed-by: Mark Freeman <markfreeman@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
src/cmd/internal/obj/arm64/asm7.go
src/image/gif/writer.go
src/runtime/stack.go
src/sort/search_test.go