Reuse the BlackFriday instance when possible

This is in heavy use in rendering, so this makes a difference:

```bash
benchmark                                                                                    old ns/op     new ns/op     delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_pages=500,tags_per_page=5,shortcodes,render-4     124551144     107743429     -13.49%

benchmark                                                                                    old allocs     new allocs     delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_pages=500,tags_per_page=5,shortcodes,render-4     528684         435118         -17.70%

benchmark                                                                                    old bytes     new bytes     delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_pages=500,tags_per_page=5,shortcodes,render-4     53306848      45147832      -15.31%
```
This commit is contained in:
Bjørn Erik Pedersen 2017-12-16 18:56:58 +01:00
parent 2511498608
commit db4b7a5c67
6 changed files with 36 additions and 33 deletions

View file

@ -98,7 +98,7 @@ func (ns *Namespace) Markdownify(s interface{}) (template.HTML, error) {
Cfg: ns.deps.Cfg,
Content: []byte(ss),
PageFmt: "markdown",
Config: ns.deps.ContentSpec.NewBlackfriday(),
Config: ns.deps.ContentSpec.BlackFriday,
},
)