]> Cypherpunks repositories - gostls13.git/commit
text/template/parse: simplify Tree.pipeline
authorDaniel Martí <mvdan@mvdan.cc>
Sun, 28 Oct 2018 20:46:58 +0000 (20:46 +0000)
committerDaniel Martí <mvdan@mvdan.cc>
Mon, 29 Oct 2018 12:20:11 +0000 (12:20 +0000)
commit37afd3e31100a06229da61549abf5210a1dae8d0
tree9a781b3e897c429c182c73b101c0af4fbd557898
parent3f3142ad99155424007b8e8182265b5b716b44ee
text/template/parse: simplify Tree.pipeline

The pipeline parsing code was unnecessarily complex. It used a for loop
with a trailing break, a complex switch, and up to seven levels of
indentation.

Instead, drop the loop in favor of a single named goto with a comment,
and flatten out the complex switch to be easier to follow. Two lines of
code are now duplicated, but they're simple and only three lines apart.

While at it, move the pipe initialization further up to remove the need
for three variables.

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