URI: 
       Cache the page's rendering context flags - hugo - [fork] hugo port for 9front
  HTML git clone git@git.drkhsh.at/hugo.git
   DIR Log
   DIR Files
   DIR Refs
   DIR Submodules
   DIR README
   DIR LICENSE
       ---
   DIR commit c8f8f48e9600f733422180d50a97bb2deea8ba75
   DIR parent 19c52ab0b5a5a8f89d43dcc2e2a15e2f53170017
  HTML Author: bep <bjorn.erik.pedersen@gmail.com>
       Date:   Wed, 21 Jan 2015 15:28:05 +0100
       
       Cache the page's rendering context flags
       
       This map can potentially be used many times for a given page, and altough the cost of re-creating the map should be minimal, caching it is simple -- and could save some GC and CPU cycles.
       
       Diffstat:
         M hugolib/page.go                     |      44 ++++++++++++++++++-------------
       
       1 file changed, 25 insertions(+), 19 deletions(-)
       ---
   DIR diff --git a/hugolib/page.go b/hugolib/page.go
       @@ -32,6 +32,7 @@ import (
                "path"
                "path/filepath"
                "strings"
       +        "sync"
                "time"
        )
        
       @@ -50,15 +51,17 @@ type Page struct {
                Tmpl            tpl.Template
                Markup          string
        
       -        extension         string
       -        contentType       string
       -        renderable        bool
       -        layout            string
       -        linkTitle         string
       -        frontmatter       []byte
       -        rawContent        []byte
       -        contentShortCodes map[string]string
       -        plain             string // TODO should be []byte
       +        extension                string
       +        contentType              string
       +        renderable               bool
       +        layout                   string
       +        linkTitle                string
       +        frontmatter              []byte
       +        rawContent               []byte
       +        contentShortCodes        map[string]string
       +        plain                    string // TODO should be []byte
       +        renderingConfigFlags     map[string]bool
       +        renderingConfigFlagsInit sync.Once
                PageMeta
                Source
                Position
       @@ -187,21 +190,24 @@ func (p *Page) renderContent(content []byte) []byte {
        }
        
        func (p *Page) getRenderingConfigFlags() map[string]bool {
       -        flags := make(map[string]bool)
        
       -        pageParam := p.GetParam("blackfriday")
       -        siteParam := viper.GetStringMap("blackfriday")
       +        p.renderingConfigFlagsInit.Do(func() {
       +                p.renderingConfigFlags = make(map[string]bool)
        
       -        flags = cast.ToStringMapBool(siteParam)
       +                pageParam := p.GetParam("blackfriday")
       +                siteParam := viper.GetStringMap("blackfriday")
        
       -        if pageParam != nil {
       -                pageFlags := cast.ToStringMapBool(pageParam)
       -                for key, value := range pageFlags {
       -                        flags[key] = value
       +                p.renderingConfigFlags = cast.ToStringMapBool(siteParam)
       +
       +                if pageParam != nil {
       +                        pageFlags := cast.ToStringMapBool(pageParam)
       +                        for key, value := range pageFlags {
       +                                p.renderingConfigFlags[key] = value
       +                        }
                        }
       -        }
       +        })
        
       -        return flags
       +        return p.renderingConfigFlags
        }
        
        func (p *Page) isRenderingFlagEnabled(flag string) bool {