aboutsummaryrefslogtreecommitdiffhomepage
path: root/hugolib
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <[email protected]>2018-02-25 10:50:44 +0100
committerBjørn Erik Pedersen <[email protected]>2018-02-25 10:50:44 +0100
commite39797fa720829dafd165aa25bfc2605700c38dc (patch)
treee823aa3909084bb2d22e4ba81c9007d9b2e6fccb /hugolib
parent00868081f624928d773a7b698654766f8cd70069 (diff)
downloadhugo-e39797fa720829dafd165aa25bfc2605700c38dc.tar.gz
hugo-e39797fa720829dafd165aa25bfc2605700c38dc.zip
hugolib: Avoid scanning entire site to find the home
See #4447
Diffstat (limited to 'hugolib')
-rw-r--r--hugolib/page_collections.go9
-rw-r--r--hugolib/site_sections.go8
2 files changed, 10 insertions, 7 deletions
diff --git a/hugolib/page_collections.go b/hugolib/page_collections.go
index 3bdb4d9ce..157d4e68d 100644
--- a/hugolib/page_collections.go
+++ b/hugolib/page_collections.go
@@ -152,6 +152,15 @@ func (*PageCollections) findPagesByKindIn(kind string, inPages Pages) Pages {
return pages
}
+func (*PageCollections) findFirstPageByKindIn(kind string, inPages Pages) *Page {
+ for _, p := range inPages {
+ if p.Kind == kind {
+ return p
+ }
+ }
+ return nil
+}
+
func (*PageCollections) findPagesByKindNotIn(kind string, inPages Pages) Pages {
var pages Pages
for _, p := range inPages {
diff --git a/hugolib/site_sections.go b/hugolib/site_sections.go
index 5de350b2f..c8bca03e3 100644
--- a/hugolib/site_sections.go
+++ b/hugolib/site_sections.go
@@ -161,18 +161,12 @@ func (s *Site) assembleSections() Pages {
)
var (
- home *Page
inPages = radix.New().Txn()
inSections = radix.New().Txn()
undecided Pages
)
- homes := s.findPagesByKind(KindHome)
- if len(homes) == 1 {
- home = homes[0]
- } else if len(homes) > 1 {
- panic("Too many homes")
- }
+ home := s.findFirstPageByKindIn(KindHome, s.Pages)
for i, p := range s.Pages {
if p.Kind != KindPage {