mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-18 21:11:19 +02:00
Avoid reading from Viper for path and URL funcs
The gain, given the "real sites benchmark" below, is obvious: ``` benchmark old ns/op new ns/op delta BenchmarkHugo-4 14497594101 13084156335 -9.75% benchmark old allocs new allocs delta BenchmarkHugo-4 57404335 48282002 -15.89% benchmark old bytes new bytes delta BenchmarkHugo-4 9933505624 9721984424 -2.13% ``` Fixes #2495
This commit is contained in:
committed by
GitHub
parent
dffd7da07c
commit
a10b2cd372
@@ -569,9 +569,9 @@ func (p *Page) analyzePage() {
|
||||
|
||||
func (p *Page) permalink() (*url.URL, error) {
|
||||
baseURL := string(p.Site.BaseURL)
|
||||
dir := strings.TrimSpace(helpers.MakePath(filepath.ToSlash(strings.ToLower(p.Source.Dir()))))
|
||||
pSlug := strings.TrimSpace(helpers.URLize(p.Slug))
|
||||
pURL := strings.TrimSpace(helpers.URLize(p.URLPath.URL))
|
||||
dir := strings.TrimSpace(p.Site.pathSpec.MakePath(filepath.ToSlash(strings.ToLower(p.Source.Dir()))))
|
||||
pSlug := strings.TrimSpace(p.Site.pathSpec.URLize(p.Slug))
|
||||
pURL := strings.TrimSpace(p.Site.pathSpec.URLize(p.URLPath.URL))
|
||||
var permalink string
|
||||
var err error
|
||||
|
||||
@@ -1171,5 +1171,6 @@ func (p *Page) TargetPath() (outfile string) {
|
||||
outfile = helpers.ReplaceExtension(p.Source.TranslationBaseName(), p.Extension())
|
||||
}
|
||||
|
||||
return p.addLangFilepathPrefix(filepath.Join(strings.ToLower(helpers.MakePath(p.Source.Dir())), strings.TrimSpace(outfile)))
|
||||
return p.addLangFilepathPrefix(filepath.Join(strings.ToLower(
|
||||
p.Site.pathSpec.MakePath(p.Source.Dir())), strings.TrimSpace(outfile)))
|
||||
}
|
||||
|
Reference in New Issue
Block a user