diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2017-05-25 21:13:03 +0300 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2017-05-26 10:42:45 +0300 |
commit | 50d11138f3e18b545c15fadf52f7b0b744bf3e7c (patch) | |
tree | 1b3a31b7e24cfd5a290adf92db7842a13458e91a /hugolib/page.go | |
parent | e0c2e798201f75ae6e9a81a7442355288c2d141b (diff) |
hugolib: Add a cache to GetPage
Looks to be slightly slower with the low number of section pages, but the 1000 regular pages seem to add value.
```
benchmark old ns/op new ns/op delta
BenchmarkGetPage-4 97.7 145 +48.41%
BenchmarkGetPageRegular-4 7933 161 -97.97%
benchmark old allocs new allocs delta
BenchmarkGetPage-4 0 0 +0.00%
BenchmarkGetPageRegular-4 0 0 +0.00%
benchmark old bytes new bytes delta
BenchmarkGetPage-4 0 0 +0.00%
BenchmarkGetPageRegular-4 0 0 +0.00%
```
Diffstat (limited to 'hugolib/page.go')
-rw-r--r-- | hugolib/page.go | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/hugolib/page.go b/hugolib/page.go index 8de4ad924..6bf42cb24 100644 --- a/hugolib/page.go +++ b/hugolib/page.go @@ -42,8 +42,9 @@ import ( ) var ( - cjk = regexp.MustCompile(`\p{Han}|\p{Hangul}|\p{Hiragana}|\p{Katakana}`) - allKinds = []string{KindPage, KindHome, KindSection, KindTaxonomy, KindTaxonomyTerm, kindRSS, kindSitemap, kindRobotsTXT, kind404} + cjk = regexp.MustCompile(`\p{Han}|\p{Hangul}|\p{Hiragana}|\p{Katakana}`) + allKindsInPages = []string{KindPage, KindHome, KindSection, KindTaxonomy, KindTaxonomyTerm, kindRSS} + allKinds = append(allKindsInPages, []string{kindSitemap, kindRobotsTXT, kind404}...) ) const ( |