• Keith Randall's avatar
    cmd/compile: don't write back unchanged slice results · d4663e13
    Keith Randall authored
    Don't write back parts of a slicing operation if they
    are unchanged from the source of the slice.  For example:
    
    x.s = x.s[0:5]         // don't write back pointer or cap
    x.s = x.s[:5]          // don't write back pointer or cap
    x.s = x.s[:5:7]        // don't write back pointer
    
    There is more to be done here, for example:
    
    x.s = x.s[:len(x.s):7] // don't write back ptr or len
    
    This CL can't handle that one yet.
    
    Fixes #14855
    
    Change-Id: Id1e1a4fa7f3076dc1a76924a7f1cd791b81909bb
    Reviewed-on: https://go-review.googlesource.com/20954Reviewed-by: 's avatarAustin Clements <austin@google.com>
    Run-TryBot: Keith Randall <khr@golang.org>
    d4663e13
writebarrier.go 3.35 KB