mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-02-07 16:04:19 +01:00
🎨 Clean code https://github.com/siyuan-note/siyuan/pull/16894
Signed-off-by: Daniel <845765@qq.com>
This commit is contained in:
parent
82647de886
commit
ac184d61fa
1 changed files with 1 additions and 14 deletions
15
kernel/cache/asset.go
vendored
15
kernel/cache/asset.go
vendored
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue