]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: short-circuit typedmemmove when dst==src
authorJosh Bleecher Snyder <josharian@gmail.com>
Mon, 13 Nov 2017 05:36:20 +0000 (21:36 -0800)
committerJosh Bleecher Snyder <josharian@gmail.com>
Tue, 27 Feb 2018 00:56:18 +0000 (00:56 +0000)
Change-Id: I855268a4c0d07ad602ec90f5da66422d3d87c5f2
Reviewed-on: https://go-review.googlesource.com/94595
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Keith Randall <khr@golang.org>
src/runtime/mbarrier.go

index c446db93d2ab25a152720b5b0048474d63250e48..b6c5ee06580612927f5aa20e87ab2027013119cd 100644 (file)
@@ -154,6 +154,9 @@ import (
 //
 //go:nosplit
 func typedmemmove(typ *_type, dst, src unsafe.Pointer) {
+       if dst == src {
+               return
+       }
        if typ.kind&kindNoPointers == 0 {
                bulkBarrierPreWrite(uintptr(dst), uintptr(src), typ.size)
        }