mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-16 20:53:59 +02:00
hugolib: Clear the page cache per render
This is a slight performance optimization with no functional effect. See #5239
This commit is contained in:
@@ -44,6 +44,12 @@ func newPageCache() *pageCache {
|
|||||||
return &pageCache{m: make(map[string][]pageCacheEntry)}
|
return &pageCache{m: make(map[string][]pageCacheEntry)}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *pageCache) clear() {
|
||||||
|
c.Lock()
|
||||||
|
defer c.Unlock()
|
||||||
|
c.m = make(map[string][]pageCacheEntry)
|
||||||
|
}
|
||||||
|
|
||||||
// get/getP gets a Pages slice from the cache matching the given key and
|
// get/getP gets a Pages slice from the cache matching the given key and
|
||||||
// all the provided Pages slices.
|
// all the provided Pages slices.
|
||||||
// If none found in cache, a copy of the first slice is created.
|
// If none found in cache, a copy of the first slice is created.
|
||||||
|
@@ -1012,6 +1012,8 @@ func (s *Site) setupSitePages() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *Site) render(config *BuildCfg, outFormatIdx int) (err error) {
|
func (s *Site) render(config *BuildCfg, outFormatIdx int) (err error) {
|
||||||
|
// Clear the global page cache.
|
||||||
|
spc.clear()
|
||||||
|
|
||||||
if outFormatIdx == 0 {
|
if outFormatIdx == 0 {
|
||||||
if err = s.preparePages(); err != nil {
|
if err = s.preparePages(); err != nil {
|
||||||
@@ -1514,8 +1516,6 @@ func (s *Site) resetBuildState() {
|
|||||||
|
|
||||||
s.expiredCount = 0
|
s.expiredCount = 0
|
||||||
|
|
||||||
spc = newPageCache()
|
|
||||||
|
|
||||||
for _, p := range s.rawAllPages {
|
for _, p := range s.rawAllPages {
|
||||||
p.subSections = Pages{}
|
p.subSections = Pages{}
|
||||||
p.parent = nil
|
p.parent = nil
|
||||||
|
Reference in New Issue
Block a user