Skip to content
This repository has been archived by the owner on Feb 24, 2024. It is now read-only.

Commit

Permalink
Replace assets map Mutex with a RWMutex (#1146)
Browse files Browse the repository at this point in the history
Once the assets map is loaded, it shouldn't change often. So, soften the read
access makes sense (and won't block rendering).
  • Loading branch information
stanislas-m authored and markbates committed Jun 28, 2018
1 parent 1bf77ff commit 69cba61
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions render/template_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"github.com/pkg/errors"
)

var assetsMutex = &sync.Mutex{}
var assetsMutex = &sync.RWMutex{}
var assetMap map[string]string

func loadManifest(manifest string) error {
Expand All @@ -22,10 +22,9 @@ func loadManifest(manifest string) error {
}

func assetPathFor(file string) string {
assetsMutex.Lock()
defer assetsMutex.Unlock()

assetsMutex.RLock()
filePath := assetMap[file]
assetsMutex.RUnlock()
if filePath == "" {
filePath = file
}
Expand Down

0 comments on commit 69cba61

Please sign in to comment.