From bd3dc0340aebdcdaeb224acccbb658b12a4d885e Mon Sep 17 00:00:00 2001 From: birdy Date: Wed, 10 May 2023 22:54:45 -0700 Subject: [PATCH] fix: skip traversal of pointers with the same cid --- 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