Use pooled buffer in replaceShortcodes
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Mon, 22 Jun 2015 17:40:12 +0000 (19:40 +0200)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Mon, 22 Jun 2015 18:30:20 +0000 (20:30 +0200)
commite764a6e638b8a9e31df6d929c071c5a289441735
tree56d4f3805facc4d07f2b0145f5d89835f4397ca5
parent67209dbfb31550cde05c7f8ea23bf67d9727d855
Use pooled buffer in replaceShortcodes

Even as a copy at the end is needed, this consumes way less memory on Go 1.4.2:

```benchmark                           old ns/op     new ns/op     delta
BenchmarkParsePage                  145979        139964        -4.12%
BenchmarkReplaceShortcodeTokens     633574        631946        -0.26%
BenchmarkShortcodeLexer             195842        187938        -4.04%

benchmark                           old allocs     new allocs     delta
BenchmarkParsePage                  87             87             +0.00%
BenchmarkReplaceShortcodeTokens     9424           9415           -0.10%
BenchmarkShortcodeLexer             274            274            +0.00%

benchmark                           old bytes     new bytes     delta
BenchmarkParsePage                  141830        141830        +0.00%
BenchmarkReplaceShortcodeTokens     35219         25385         -27.92%
BenchmarkShortcodeLexer             30178         30177         -0.00%
```
See #1148
hugolib/shortcode.go