go/src/text
Rob Pike 24a088d20a text/template: efficient reporting of line numbers
Instead of scanning the text to count newlines, which is n², keep track as we go
and store the line number in the token.

benchmark                 old ns/op      new ns/op     delta
BenchmarkParseLarge-4     1589721293     38783310      -97.56%

Fixes #17851

Change-Id: I231225c61e667535e2ce55cd2facea6d279cc59d
Reviewed-on: https://go-review.googlesource.com/33234
Run-TryBot: Rob Pike <r@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-11-15 00:42:33 +00:00
..
scanner text/scanner: better error message if no error handler is installed 2016-05-25 15:44:28 +00:00
tabwriter all: freeze net/rpc and reword the 'frozen' message in other frozen packages 2016-10-26 16:11:07 +00:00
template text/template: efficient reporting of line numbers 2016-11-15 00:42:33 +00:00