parser: Improve TOML frontmatter parser performance

Difference between toml.Load(string(datum)) and
toml.LoadReader(bytes.NewReader(datum)):
benchmark           old ns/op     new ns/op     delta
BenchmarkLoad-4     82068         78489         -4.36%

benchmark           old allocs     new allocs     delta
BenchmarkLoad-4     494            493            -0.20%

benchmark           old bytes     new bytes     delta
BenchmarkLoad-4     17009         16913         -0.56%
This commit is contained in:
Albert Nigmatzianov 2017-03-20 10:47:46 +05:00 committed by Bjørn Erik Pedersen
parent 68f4cd829e
commit d3cd68e656

View file

@ -176,8 +176,7 @@ func HandleTOMLMetaData(datum []byte) (interface{}, error) {
m := map[string]interface{}{}
datum = removeTOMLIdentifier(datum)
tree, err := toml.Load(string(datum))
tree, err := toml.LoadReader(bytes.NewReader(datum))
if err != nil {
return m, err
}