Skip to content

Commit

Permalink
Remove unneccesary logic from Tree GC (yorkie-team#581)
Browse files Browse the repository at this point in the history
  • Loading branch information
JOOHOJANG authored Jul 14, 2023
1 parent 12d410f commit eed0a08
Showing 1 changed file with 3 additions and 20 deletions.
23 changes: 3 additions & 20 deletions pkg/document/crdt/tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -324,27 +324,10 @@ func (t *Tree) purgeRemovedNodesBefore(ticket *time.Ticket) (int, error) {
}
}

if err := index.TraverseAll(t.IndexTree, func(node *index.Node[*TreeNode], depth int) error {
if _, ok := nodesToBeRemoved[node.Value]; ok {
parent := node.Parent

if parent == nil {
count--
delete(nodesToBeRemoved, node.Value)
return nil
}

if err := parent.RemoveChild(node); err != nil {
return err
}
}

return nil
}); err != nil {
return 0, err
}

for node := range nodesToBeRemoved {
if err := node.IndexTreeNode.Parent.RemoveChild(node.IndexTreeNode); err != nil {
return 0, err
}
t.NodeMapByPos.Remove(node.Pos)
t.Purge(node)
delete(t.removedNodeMap, node.Pos.CreatedAt.StructureAsString()+":"+strconv.Itoa(node.Pos.Offset))
Expand Down

0 comments on commit eed0a08

Please sign in to comment.