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

Replace assets map Mutex with a RWMutex #1146

Merged
merged 1 commit into from
Jun 28, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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