1
0
Fork 0
mirror of https://github.com/anyproto/any-sync.git synced 2025-06-07 21:47:02 +09:00

Remove nested locks in treestats collector

This commit is contained in:
Mikhail Rakhmanov 2025-06-04 15:38:51 +02:00
parent 95ba16876a
commit 1bf2a994c2
No known key found for this signature in database
GPG key ID: DED12CFEF5B8396B

View file

@ -25,9 +25,13 @@ func (t *TreeStatsCollector) Register(tree *syncTree) {
func (t *TreeStatsCollector) Collect() []TreeStats {
t.mutex.Lock()
defer t.mutex.Unlock()
stats := make([]TreeStats, 0, len(t.trees))
trees := make([]*syncTree, 0, len(t.trees))
for _, tree := range t.trees {
trees = append(trees, tree)
}
t.mutex.Unlock()
stats := make([]TreeStats, 0, len(t.trees))
for _, tree := range trees {
tree.Lock()
stats = append(stats, TreeStats{
TreeLen: tree.Len(),