Migrate old externs 8/x

This commit is contained in:
2026-06-17 09:03:19 +08:00
parent c2fb5b205a
commit 00fe7ca3bb
33 changed files with 228 additions and 119 deletions
+11 -6
View File
@@ -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.