Skip to content

Commit

Permalink
parser: Improve TOML frontmatter parser performance
Browse files Browse the repository at this point in the history
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%
  • Loading branch information
n10v authored and bep committed Mar 20, 2017
1 parent 68f4cd8 commit d3cd68e
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions parser/frontmatter.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit d3cd68e

Please sign in to comment.