go/src/sort
Axel Wagner a18294bb6a 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>
2025-11-23 03:49:34 -08:00
..
example_interface_test.go
example_keys_test.go all: fix some function names and typos in comment 2024-11-21 22:16:20 +00:00
example_multi_test.go all: fix some function names and typos in comment 2024-11-21 22:16:20 +00:00
example_search_test.go sort: add examples for SearchStrings, SliceIsSorted 2024-12-03 17:07:42 +00:00
example_test.go sort: add examples for SearchStrings, SliceIsSorted 2024-12-03 17:07:42 +00:00
example_wrapper_test.go
export_test.go sort: use pdqsort 2022-04-13 20:16:24 +00:00
gen_sort_variants.go all: drop old +build lines 2023-10-19 23:33:27 +00:00
search.go sort: add available godoc link 2023-11-28 16:40:32 +00:00
search_test.go cmd/internal/obj/arm64, image/gif, runtime, sort: use math/bits to calculate log2 2025-11-23 03:49:34 -08:00
slice.go sort: add available godoc link 2023-11-28 16:40:32 +00:00
sort.go sort: clarify Less doc 2025-07-07 09:13:08 -07:00
sort_slices_benchmark_test.go std: remove unused declarations 2025-09-25 11:38:17 -07:00
sort_test.go sort: add example for Find 2024-07-16 17:55:15 +00:00
zsortfunc.go sort: use pdqsort 2022-04-13 20:16:24 +00:00
zsortinterface.go sort: use pdqsort 2022-04-13 20:16:24 +00:00