• Ariel Mashraki's avatar
    text/template/parse: use strings.Builder in String methods · 4f13a9c5
    Ariel Mashraki authored
    As mentioned in godoc, strings.Builder is more efficient for
    concatenating and building strings.
    Running a simple bench test on VariableNode.String() gives:
    
    benchmark                     old ns/op     new ns/op     delta
    BenchmarkParseLarge-8         25676831      24453285      -4.77%
    BenchmarkVariableString-8     296           115           -61.15%
    
    benchmark                     old allocs     new allocs     delta
    BenchmarkVariableString-8     8              3              -62.50%
    
    benchmark                     old bytes     new bytes     delta
    BenchmarkVariableString-8     112           72            -35.71%
    
    Change-Id: I13c9340080738fcad1edeed859d33ba608e4b05a
    Reviewed-on: https://go-review.googlesource.com/c/go/+/198078Reviewed-by: default avatarEmmanuel Odeke <emm.odeke@gmail.com>
    Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
    TryBot-Result: Gobot Gobot <gobot@golang.org>
    4f13a9c5
parse_test.go 19 KB