From e93eb2843c6b6b8e0e6c5e9eb1a4417328055ec6 Mon Sep 17 00:00:00 2001 From: Kevin Burke Date: Wed, 2 Aug 2017 22:24:22 -0700 Subject: [PATCH] strings: avoid unnecessary variable setting MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit We initialize fieldStart to 0, then set it to i without ever reading 0, so we might as well just initialize it to i. Change-Id: I17905b25d54a62b6bc76f915353756ed5eb6972b Reviewed-on: https://go-review.googlesource.com/52933 Reviewed-by: Martin Möhrmann Reviewed-by: Avelino Reviewed-by: Brad Fitzpatrick --- src/strings/strings.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/strings/strings.go b/src/strings/strings.go index 0c836c09d4..52466e924d 100644 --- a/src/strings/strings.go +++ b/src/strings/strings.go @@ -363,7 +363,6 @@ func Fields(s string) []string { // a non-ASCII rune needs to be decoded and checked // if it corresponds to a space. a := make([]string, 0, n) - fieldStart := 0 i := 0 // Skip spaces in the front of the input. for i < len(s) { @@ -380,7 +379,7 @@ func Fields(s string) []string { i += w } } - fieldStart = i + fieldStart := i for i < len(s) { if c := s[i]; c < utf8.RuneSelf { if asciiSpace[c] == 0 { -- 2.48.1