hugolib: Pre-allocate some slices - hugo - [fork] hugo port for 9front
 (HTM) git clone git@git.drkhsh.at/hugo.git
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) Submodules
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit a9be687b81df01c7343f78f0d3760042f467baa4
 (DIR) parent b32ffed6abc67646cad89e163846f3ffef29cec8
 (HTM) Author: Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
       Date:   Sat, 11 Nov 2017 09:39:43 +0100
       
       hugolib: Pre-allocate some slices
       
       Diffstat:
         M hugolib/pageGroup.go                |       7 ++++---
         M hugolib/page_collections.go         |       6 +++---
       
       2 files changed, 7 insertions(+), 6 deletions(-)
       ---
 (DIR) diff --git a/hugolib/pageGroup.go b/hugolib/pageGroup.go
       @@ -142,9 +142,10 @@ func (p Pages) GroupBy(key string, order ...string) (PagesGroup, error) {
                        tmp.SetMapIndex(fv, reflect.Append(tmp.MapIndex(fv), ppv))
                }
        
       -        var r []PageGroup
       -        for _, k := range sortKeys(tmp.MapKeys(), direction) {
       -                r = append(r, PageGroup{Key: k.Interface(), Pages: tmp.MapIndex(k).Interface().([]*Page)})
       +        sortedKeys := sortKeys(tmp.MapKeys(), direction)
       +        r := make([]PageGroup, len(sortedKeys))
       +        for i, k := range sortedKeys {
       +                r[i] = PageGroup{Key: k.Interface(), Pages: tmp.MapIndex(k).Interface().([]*Page)}
                }
        
                return r, nil
 (DIR) diff --git a/hugolib/page_collections.go b/hugolib/page_collections.go
       @@ -76,10 +76,10 @@ func (c *PageCollections) refreshPageCaches() {
                        }
                }
        
       -        var partitions []cache.Partition
       +        partitions := make([]cache.Partition, len(allKindsInPages))
        
       -        for _, kind := range allKindsInPages {
       -                partitions = append(partitions, cache.Partition{Key: kind, Load: cacheLoader(kind)})
       +        for i, kind := range allKindsInPages {
       +                partitions[i] = cache.Partition{Key: kind, Load: cacheLoader(kind)}
                }
        
                c.pageCache = cache.NewPartitionedLazyCache(partitions...)