From a0b13f309e1bceb6487bb4913bd8c80d93b870a8 Mon Sep 17 00:00:00 2001 From: Po-Chun Chang <31112892+birdychang@users.noreply.github.com> Date: Thu, 11 May 2023 00:42:15 -0700 Subject: [PATCH] fix: skip traversal of pointers with the same cid (#109) --- diff.go | 3 +++ diff_parallel.go | 3 +++ 2 files changed, 6 insertions(+) diff --git a/diff.go b/diff.go index 3af3d81..a4b7d29 100644 --- a/diff.go +++ b/diff.go @@ -80,6 +80,9 @@ func diffNode(ctx context.Context, pre, cur *Node, depth int) ([]*Change, error) // both pointers are shards, recurse down the tree. if prePointer.isShard() && curPointer.isShard() { + if prePointer.Link == curPointer.Link { + continue + } preChild, err := prePointer.loadChild(ctx, pre.store, pre.bitWidth, pre.hash) if err != nil { return nil, err diff --git a/diff_parallel.go b/diff_parallel.go index 818cf07..44ebbf6 100644 --- a/diff_parallel.go +++ b/diff_parallel.go @@ -192,6 +192,9 @@ func (s *diffScheduler) work(ctx context.Context, todo *task, results chan *Chan switch { // both pointers are shards, recurse down the tree. case prePointer.isShard() && curPointer.isShard(): + if prePointer.Link == curPointer.Link { + return nil + } preChild, err := prePointer.loadChild(ctx, pre.store, pre.bitWidth, pre.hash) if err != nil { return err