From 93a79bbcc0de229679ddeb2ad662ec8cea5b3de6 Mon Sep 17 00:00:00 2001 From: Ariel Mashraki Date: Tue, 1 Oct 2019 21:12:59 +0300 Subject: [PATCH] text/template/parse: remove duplication in peekNonSpace 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 TryBot-Result: Gobot Gobot Reviewed-by: Rob Pike --- src/text/template/parse/parse.go | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/text/template/parse/parse.go b/src/text/template/parse/parse.go index 7c35b0ff3d..c9b80f4a24 100644 --- a/src/text/template/parse/parse.go +++ b/src/text/template/parse/parse.go @@ -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 } -- 2.50.0