From d3cd68e65646c77da94a9322758519e2ef821ec6 Mon Sep 17 00:00:00 2001 From: Albert Nigmatzianov Date: Mon, 20 Mar 2017 10:47:46 +0500 Subject: [PATCH] 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% --- parser/frontmatter.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/parser/frontmatter.go b/parser/frontmatter.go index d97bc4c4..b773fe5c 100644 --- a/parser/frontmatter.go +++ b/parser/frontmatter.go @@ -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 } -- 2.30.2