Re: [go-nuts] Improvement in text/template/parse/lex.go

2016-07-11 Thread Rob Pike
Seems reasonable (although I must add that if you have a situation where the overhead of lexing your templates is significant, you must be doing something odd). Feel free to send a CL. -rob On Mon, Jul 11, 2016 at 1:28 PM, 'Paul Borman' via golang-nuts < golang-nuts@googlegroups.com> wrote: > H

Re: [go-nuts] Improvement in text/template/parse/lex.go

2016-07-11 Thread 'Paul Borman' via golang-nuts
Here are a set of results using benchcmp. I also included a new benchmark, the code from example_test.go that executes a template 3 times with different input. The template is: Dear {{.Name}}, {{if .Attended}} It was a pleasure to see you at the wedding. {{- else}} It is a shame you couldn't mak

[go-nuts] Improvement in text/template/parse/lex.go

2016-07-11 Thread 'Paul Borman' via golang-nuts
I was looking at text/template/parse/lex.go and noticed it seemed to be very inefficient in how it searched for {{ in its input. I rewrote lexText to us strings.Index rather than calling l.next() for every single rune in the string. The results were up to a 9x speed improvement, depending on the