Source File
cache.go
Belonging Package
github.com/evanw/esbuild/internal/cache
package cache
import (
)
type CacheSet struct {
SourceIndexCache SourceIndexCache
FSCache FSCache
CSSCache CSSCache
JSONCache JSONCache
JSCache JSCache
}
func () *CacheSet {
return &CacheSet{
SourceIndexCache: SourceIndexCache{
entries: make(map[sourceIndexKey]uint32),
nextSourceIndex: runtime.SourceIndex + 1,
},
FSCache: FSCache{
entries: make(map[string]*fsEntry),
},
CSSCache: CSSCache{
entries: make(map[logger.Path]*cssCacheEntry),
},
JSONCache: JSONCache{
entries: make(map[logger.Path]*jsonCacheEntry),
},
JSCache: JSCache{
entries: make(map[logger.Path]*jsCacheEntry),
},
}
}
type SourceIndexCache struct {
mutex sync.Mutex
entries map[sourceIndexKey]uint32
nextSourceIndex uint32
}
type SourceIndexKind uint8
const (
SourceIndexNormal SourceIndexKind = iota
SourceIndexJSStubForCSS
)
type sourceIndexKey struct {
path logger.Path
kind SourceIndexKind
}
func ( *SourceIndexCache) () uint32 {
.mutex.Lock()
defer .mutex.Unlock()
const = 16
return .nextSourceIndex +
}
func ( *SourceIndexCache) ( logger.Path, SourceIndexKind) uint32 {
:= sourceIndexKey{path: , kind: }
.mutex.Lock()
defer .mutex.Unlock()
if , := .entries[]; {
return
}
:= .nextSourceIndex
.nextSourceIndex++
.entries[] =
return
![]() |
The pages are generated with Golds v0.3.2-preview. (GOOS=darwin GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds. |