From 3c8101c7e4b80794c6c61acf7477fee136f8c79e Mon Sep 17 00:00:00 2001 From: Josh Bleecher Snyder Date: Tue, 28 May 2019 14:29:28 -0700 Subject: [PATCH] cmd/compile: use optimized slice zeroing in deadcode Minor cleanup. Passes toolstash-check. Change-Id: I97a027c4ca49ded593e9c7989e9e091ab9336fa3 Reviewed-on: https://go-review.googlesource.com/c/go/+/227318 Run-TryBot: Josh Bleecher Snyder TryBot-Result: Gobot Gobot Reviewed-by: Matthew Dempsky --- src/cmd/compile/internal/ssa/deadcode.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/cmd/compile/internal/ssa/deadcode.go b/src/cmd/compile/internal/ssa/deadcode.go index b79ec7c2f6..395c1617e5 100644 --- a/src/cmd/compile/internal/ssa/deadcode.go +++ b/src/cmd/compile/internal/ssa/deadcode.go @@ -242,8 +242,9 @@ func deadcode(f *Func) { f.NamedValues[name] = values[:j] } } - for k := len(f.Names) - 1; k >= i; k-- { - f.Names[k] = LocalSlot{} + clearNames := f.Names[i:] + for j := range clearNames { + clearNames[j] = LocalSlot{} } f.Names = f.Names[:i] @@ -311,8 +312,9 @@ func deadcode(f *Func) { i++ } } - for j := i; j < len(f.WBLoads); j++ { - f.WBLoads[j] = nil + clearWBLoads := f.WBLoads[i:] + for j := range clearWBLoads { + clearWBLoads[j] = nil } f.WBLoads = f.WBLoads[:i]