]> Cypherpunks repositories - gostls13.git/commit
runtime: short-circuit typedslicecopy when dstp == srcp
authorJosh Bleecher Snyder <josharian@gmail.com>
Mon, 13 Nov 2017 06:11:51 +0000 (22:11 -0800)
committerJosh Bleecher Snyder <josharian@gmail.com>
Thu, 15 Feb 2018 15:05:15 +0000 (15:05 +0000)
commit3658299f449e63026caf08a02eba855aab6755b6
treeab757055305075fa46944cc7a13069525008b969
parentbf9f1c15035ab9bb695a9a3504e465a1896b4b8c
runtime: short-circuit typedslicecopy when dstp == srcp

If copying from a slice to itself, skip the write barriers
and actual memory copies.

This happens in practice in code like this snippet from
the trim pass in the compiler, when k ends up being 0:

copy(s.Values[k:], s.Values[:m])

Change-Id: Ie6924acfd56151f874d87f1d7f1f74320b4c4f10
Reviewed-on: https://go-review.googlesource.com/94023
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
src/runtime/mbarrier.go