forked from Botanical/BotanJS
Migrate old externs 8/x
This commit is contained in:
@@ -41,6 +41,8 @@ type Resolver struct {
|
||||
Root string
|
||||
Map *classmap.Map
|
||||
|
||||
DisableCache bool
|
||||
|
||||
externMu sync.RWMutex
|
||||
externCache map[string]closure.SourceInput
|
||||
}
|
||||
@@ -308,12 +310,15 @@ func (r *Resolver) GetExterns(files []string) ([]closure.SourceInput, error) {
|
||||
}
|
||||
|
||||
func (r *Resolver) getExtern(f string) (closure.SourceInput, bool, error) {
|
||||
// Fast path: read cache.
|
||||
r.externMu.RLock()
|
||||
src, ok := r.externCache[f]
|
||||
r.externMu.RUnlock()
|
||||
if ok {
|
||||
return src, true, nil
|
||||
|
||||
if !r.DisableCache {
|
||||
// Fast path: read cache.
|
||||
r.externMu.RLock()
|
||||
src, ok := r.externCache[f]
|
||||
r.externMu.RUnlock()
|
||||
if ok {
|
||||
return src, true, nil
|
||||
}
|
||||
}
|
||||
|
||||
// Slow path: read file.
|
||||
|
||||
Reference in New Issue
Block a user