]> Cypherpunks repositories - gostls13.git/commit
text/template: improve lexer performance in finding left delimiters.
authorPaul Borman <borman@google.com>
Tue, 12 Jul 2016 15:54:09 +0000 (08:54 -0700)
committerRob Pike <r@golang.org>
Tue, 13 Sep 2016 12:51:13 +0000 (12:51 +0000)
commit07b8011393dc3d3a78b3cd0857a31da339985994
tree2099a7bcc49acd21bef70d46ba43fc7f5f070623
parent8f9671d11a219d8fc9a6176ddf9939e743982ffc
text/template: improve lexer performance in finding left delimiters.

The existing implementation calls l.next for each run up to the next
instance of the left delimiter ({{).  For ascii text, this is multiple
function calls per byte.  Change to use strings.Index to find the left
delimiter.  The performace improvement ranges from 1:1 (no text outside
of {{}}'s) to multiple times faster (9:1 was seen on 8K of text with no
{{ }}'s).

Change-Id: I2f82bea63b78b6714f09a725f7b2bbb00a3448a3
Reviewed-on: https://go-review.googlesource.com/24863
Reviewed-by: Rob Pike <r@golang.org>
Run-TryBot: Rob Pike <r@golang.org>
src/text/template/parse/lex.go