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/pagination.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/pagination.go')
-rw-r--r-- | hugolib/pagination.go | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/hugolib/pagination.go b/hugolib/pagination.go index 5bba5d89f..81f3e0cda 100644 --- a/hugolib/pagination.go +++ b/hugolib/pagination.go @@ -508,16 +508,16 @@ func newPaginator(elements []paginatedElement, total, size int, urlFactory pagin } func newPaginationURLFactory(pathElements ...string) paginationURLFactory { - paginatePath := helpers.Config().GetString("paginatePath") + pathSpec := helpers.CurrentPathSpec() return func(page int) string { var rel string if page == 1 { rel = fmt.Sprintf("/%s/", path.Join(pathElements...)) } else { - rel = fmt.Sprintf("/%s/%s/%d/", path.Join(pathElements...), paginatePath, page) + rel = fmt.Sprintf("/%s/%s/%d/", path.Join(pathElements...), pathSpec.PaginatePath(), page) } - return helpers.URLizeAndPrep(rel) + return pathSpec.URLizeAndPrep(rel) } } |