Optimize the performance of document tree flashcard loading Fix https://github.com/siyuan-note/siyuan/issues/7967

This commit is contained in:
Liang Ding 2023-04-12 19:41:19 +08:00
parent f30e9893e8
commit 758f65fdff
No known key found for this signature in database
GPG key ID: 136F30F901A2231D
2 changed files with 18 additions and 27 deletions

View file

@ -180,6 +180,21 @@ func RemoveBlockTreesByRootID(rootID string) {
}
}
func GetBlockTreesByPathPrefix(pathPrefix string) (ret []*BlockTree) {
blockTrees.Range(func(key, value interface{}) bool {
slice := value.(*btSlice)
slice.m.Lock()
for _, b := range slice.data {
if strings.HasPrefix(b.Path, pathPrefix) {
ret = append(ret, b)
}
}
slice.m.Unlock()
return true
})
return
}
func RemoveBlockTreesByPathPrefix(pathPrefix string) {
var ids []string
blockTrees.Range(func(key, value interface{}) bool {