]> Cypherpunks repositories - gostls13.git/commit
bytes,slices,strings: optimize Repeat a bit
authorJes Cok <xigua67damn@gmail.com>
Thu, 1 Aug 2024 16:18:06 +0000 (16:18 +0000)
committerGopher Robot <gobot@golang.org>
Thu, 1 Aug 2024 21:32:50 +0000 (21:32 +0000)
commit67c3f012cf5bfd69841c74666243281f0698e09f
treeee612f3b0c4d16414946cd84919fb152d42aed7f
parente50913cefcdb590cdf7d9432455de2847ef93851
bytes,slices,strings: optimize Repeat a bit

Like slices.Repeat, use math/bits.Mul to detect overflow in order to
avoid a divide which is slow.

While here, also use builtin min/max to simplify code.

Change-Id: I4a6d8cd5df97fa75f4e324d4be1405ce53c03d31
GitHub-Last-Rev: 54ba5c7126b1d4a301e95d664b5f6deee6d579d9
GitHub-Pull-Request: golang/go#68704
Reviewed-on: https://go-review.googlesource.com/c/go/+/602475
Auto-Submit: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
src/bytes/bytes.go
src/slices/slices.go
src/strings/strings.go