diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2016-10-24 13:45:30 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-10-24 13:45:30 +0200 |
commit | a10b2cd372798c4e4b862f0ec03010d2aea2ff1e (patch) | |
tree | f768c420aac0008e4d118709e13fda278a7588c5 /hugolib/page_permalink_test.go | |
parent | dffd7da07c3fb198acfa6c4664b53132c4cabe55 (diff) |
Avoid reading from Viper for path and URL funcs
The gain, given the "real sites benchmark" below, is obvious:
```
benchmark old ns/op new ns/op delta
BenchmarkHugo-4 14497594101 13084156335 -9.75%
benchmark old allocs new allocs delta
BenchmarkHugo-4 57404335 48282002 -15.89%
benchmark old bytes new bytes delta
BenchmarkHugo-4 9933505624 9721984424 -2.13%
```
Fixes #2495
Diffstat (limited to 'hugolib/page_permalink_test.go')
-rw-r--r-- | hugolib/page_permalink_test.go | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/hugolib/page_permalink_test.go b/hugolib/page_permalink_test.go index d185bebab..eb3a6c878 100644 --- a/hugolib/page_permalink_test.go +++ b/hugolib/page_permalink_test.go @@ -18,6 +18,7 @@ import ( "path/filepath" "testing" + "github.com/spf13/hugo/helpers" "github.com/spf13/hugo/source" "github.com/spf13/viper" ) @@ -59,17 +60,18 @@ func TestPermalink(t *testing.T) { } viper.Set("DefaultExtension", "html") - for i, test := range tests { viper.Set("uglyurls", test.uglyURLs) viper.Set("canonifyurls", test.canonifyURLs) + info := newSiteInfo(siteBuilderCfg{baseURL: string(test.base), language: helpers.NewDefaultLanguage()}) + p := &Page{ Node: Node{ URLPath: URLPath{ Section: "z", URL: test.url, }, - Site: newSiteInfoDefaultLanguage(string(test.base)), + Site: &info, }, Source: Source{File: *source.NewFile(filepath.FromSlash(test.file))}, } |