]> Cypherpunks repositories - gostls13.git/commitdiff
text/template/parse: remove duplication in peekNonSpace
authorAriel Mashraki <ariel@mashraki.co.il>
Tue, 1 Oct 2019 18:12:59 +0000 (21:12 +0300)
committerRob Pike <r@golang.org>
Tue, 1 Oct 2019 20:30:37 +0000 (20:30 +0000)
nextNonSpace has an identical code except the call to
backup at the end.

Change-Id: Iefa5b13950007da38323a800fb6b0ce3d436254b
Reviewed-on: https://go-review.googlesource.com/c/go/+/198277
Run-TryBot: Rob Pike <r@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
src/text/template/parse/parse.go

index 7c35b0ff3d89169d7b249cc55003670b36644725..c9b80f4a24836846a54bba632c75c13fe9310169 100644 (file)
@@ -108,13 +108,8 @@ func (t *Tree) nextNonSpace() (token item) {
 }
 
 // peekNonSpace returns but does not consume the next non-space token.
-func (t *Tree) peekNonSpace() (token item) {
-       for {
-               token = t.next()
-               if token.typ != itemSpace {
-                       break
-               }
-       }
+func (t *Tree) peekNonSpace() item {
+       token := t.nextNonSpace()
        t.backup()
        return token
 }