]> Cypherpunks repositories - gostls13.git/commit
bytes: return early in Repeat if count is 0
authorTobias Klauser <tklauser@distanz.ch>
Sat, 9 Mar 2019 13:11:40 +0000 (14:11 +0100)
committerTobias Klauser <tobias.klauser@gmail.com>
Sat, 9 Mar 2019 14:17:13 +0000 (14:17 +0000)
commit0e9d7d430b1aa74a58054a6a69aa3fb37353168d
tree4959d9f1112dc72296336b6259c00f0b905842fe
parentca8354843ef9f30207efd0a40bb6c53e7ba86892
bytes: return early in Repeat if count is 0

This matches the implementation of strings.Repeat and slightly increases
performance:

name      old time/op  new time/op  delta
Repeat-8   145ns ±12%   125ns ±29%  -13.35%  (p=0.009 n=10+10)

Change-Id: Ic0a0e2ea9e36591286a49def320ddb67fe0b2c50
Reviewed-on: https://go-review.googlesource.com/c/go/+/166399
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
src/bytes/bytes.go