diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2021-07-27 19:07:10 +0200 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2021-07-28 11:51:13 +0200 |
commit | a3701e09313695d4a0f6fb0eb7844c1a4befc07a (patch) | |
tree | 443c85a8b6cbf841155efad4aa99ead8c2824720 /hugolib | |
parent | 40b6016cf3f7aac541b042d32e3a162411fd9cd0 (diff) |
Switch to go-toml v2
We have been using `go-toml` for language files only. This commit makes it the only TOML library.
It's spec compliant and very fast.
A benchark building a site with 200 pages with TOML front matter:
```bash
name old time/op new time/op delta
SiteNew/Regular_TOML_front_matter-16 48.5ms ± 1% 47.1ms ± 1% -2.85% (p=0.029 n=4+4)
name old alloc/op new alloc/op delta
SiteNew/Regular_TOML_front_matter-16 16.9MB ± 0% 16.7MB ± 0% -1.56% (p=0.029 n=4+4)
name old allocs/op new allocs/op delta
SiteNew/Regular_TOML_front_matter-16 302k ± 0% 296k ± 0% -2.20% (p=0.029 n=4+4)
```
Note that the front matter unmarshaling is only a small part of building a site, so the above is very good.
Fixes #8801
Diffstat (limited to 'hugolib')
-rw-r--r-- | hugolib/config_test.go | 24 | ||||
-rw-r--r-- | hugolib/configdir_test.go | 4 |
2 files changed, 14 insertions, 14 deletions
diff --git a/hugolib/config_test.go b/hugolib/config_test.go index 575931975..bda1c7fb5 100644 --- a/hugolib/config_test.go +++ b/hugolib/config_test.go @@ -287,13 +287,13 @@ name = "menu-theme" "pl1": "p1-en-main", }, "menus": maps.Params{ - "main": []map[string]interface{}{ - { + "main": []interface{}{ + map[string]interface{}{ "name": "menu-lang-en-main", }, }, - "theme": []map[string]interface{}{ - { + "theme": []interface{}{ + map[string]interface{}{ "name": "menu-lang-en-theme", }, }, @@ -307,18 +307,18 @@ name = "menu-theme" "pl2": "p2-nb-theme", }, "menus": maps.Params{ - "main": []map[string]interface{}{ - { + "main": []interface{}{ + map[string]interface{}{ "name": "menu-lang-nb-main", }, }, - "theme": []map[string]interface{}{ - { + "theme": []interface{}{ + map[string]interface{}{ "name": "menu-lang-nb-theme", }, }, - "top": []map[string]interface{}{ - { + "top": []interface{}{ + map[string]interface{}{ "name": "menu-lang-nb-top", }, }, @@ -393,8 +393,8 @@ name = "menu-theme" "en": maps.Params{ "languagename": "English", "menus": maps.Params{ - "main": []map[string]interface{}{ - { + "main": []interface{}{ + map[string]interface{}{ "name": "menu-theme", }, }, diff --git a/hugolib/configdir_test.go b/hugolib/configdir_test.go index aa1013ec0..b3fc71e58 100644 --- a/hugolib/configdir_test.go +++ b/hugolib/configdir_test.go @@ -119,10 +119,10 @@ p3 = "p3params_no_production" c.Assert(cfg.GetString("params.p3"), qt.Equals, "p3params_development") c.Assert(cfg.GetString("languages.no.params.p3"), qt.Equals, "p3params_no_development") - c.Assert(len(cfg.Get("menus.docs").(([]map[string]interface{}))), qt.Equals, 2) + c.Assert(len(cfg.Get("menus.docs").([]interface{})), qt.Equals, 2) noMenus := cfg.Get("languages.no.menus.docs") c.Assert(noMenus, qt.Not(qt.IsNil)) - c.Assert(len(noMenus.(([]map[string]interface{}))), qt.Equals, 1) + c.Assert(len(noMenus.([]interface{})), qt.Equals, 1) } func TestLoadConfigDirError(t *testing.T) { |