diff --git a/kernel/cache/asset.go b/kernel/cache/asset.go index fce48acdb..d3386e3a2 100644 --- a/kernel/cache/asset.go +++ b/kernel/cache/asset.go @@ -104,19 +104,6 @@ var ( assetsLock = sync.Mutex{} ) -// GetAssets 返回所有资源的副本 -func GetAssets() (ret map[string]*Asset) { - assetsLock.Lock() - defer assetsLock.Unlock() - - // 指定长度避免分配新内存时扩容和迁移 - ret = make(map[string]*Asset, len(assetsCache)) - for k, v := range assetsCache { - ret[k] = v - } - return -} - // IterateAssets 遍历所有资源,适合只读场景 func IterateAssets(fn func(path string, asset *Asset) bool) { assetsLock.Lock() @@ -134,7 +121,7 @@ func FilterAssets(filter func(path string, asset *Asset) bool) (ret map[string]* assetsLock.Lock() defer assetsLock.Unlock() - ret = make(map[string]*Asset) + ret = map[string]*Asset{} for path, asset := range assetsCache { if filter(path, asset) { ret[path] = asset