aboutsummaryrefslogtreecommitdiff
path: root/src/text
diff options
context:
space:
mode:
authorAriel Mashraki <ariel@mashraki.co.il>2019-10-01 21:12:59 +0300
committerRob Pike <r@golang.org>2019-10-01 20:30:37 +0000
commit93a79bbcc0de229679ddeb2ad662ec8cea5b3de6 (patch)
treee645a1509e2dc50631886b5a2584b0cb858b20d6 /src/text
parent86cd6c2ee5c5e4c5b5edf4ea8d1c85f80d9706a8 (diff)
downloadgo-93a79bbcc0de229679ddeb2ad662ec8cea5b3de6.tar.gz
go-93a79bbcc0de229679ddeb2ad662ec8cea5b3de6.zip
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 <r@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Rob Pike <r@golang.org>
Diffstat (limited to 'src/text')
-rw-r--r--src/text/template/parse/parse.go9
1 files 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
}