Skip to content

Commit 3442163

Browse files
committed
Revert "syncslice, too"
This reverts commit 0ab8341.
1 parent 36721b2 commit 3442163

File tree

3 files changed

+14
-333
lines changed

3 files changed

+14
-333
lines changed

internal/verifier/compare.go

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import (
77

88
"github.com/10gen/migration-verifier/internal/types"
99
"github.com/10gen/migration-verifier/syncmap"
10-
"github.com/10gen/migration-verifier/syncslice"
1110
"github.com/pkg/errors"
1211
"go.mongodb.org/mongo-driver/bson"
1312
"go.mongodb.org/mongo-driver/mongo"
@@ -67,9 +66,9 @@ func (verifier *Verifier) compareDocsFromChannels(
6766
types.ByteCount,
6867
error,
6968
) {
70-
results := syncslice.New[VerificationResult]()
71-
var srcDocCount types.DocumentCount
72-
var srcByteCount types.ByteCount
69+
results := []VerificationResult{}
70+
var docCount types.DocumentCount
71+
var byteCount types.ByteCount
7372

7473
mapKeyFieldNames := make([]string, 1+len(task.QueryFilter.ShardKeys))
7574
mapKeyFieldNames[0] = "_id"
@@ -132,7 +131,7 @@ func (verifier *Verifier) compareDocsFromChannels(
132131
return errors.Wrap(err, "failed to compare documents")
133132
}
134133

135-
results = results.Push(mismatches...)
134+
results = append(results, mismatches...)
136135

137136
return nil
138137
}
@@ -167,8 +166,8 @@ func (verifier *Verifier) compareDocsFromChannels(
167166
srcClosed = true
168167
break
169168
}
170-
srcDocCount++
171-
srcByteCount += types.ByteCount(len(doc))
169+
docCount++
170+
byteCount += types.ByteCount(len(doc))
172171

173172
err := handleNewDoc(doc, true)
174173

@@ -230,8 +229,12 @@ func (verifier *Verifier) compareDocsFromChannels(
230229
// At this point, any documents left in the cache maps are simply
231230
// missing on the other side. We add results for those.
232231

232+
// We might as well pre-grow the slice:
233+
results = slices.Grow(results, srcCache.Len()+dstCache.Len())
234+
233235
srcCache.Range(func(_ string, doc bson.Raw) bool {
234-
results = results.Push(
236+
results = append(
237+
results,
235238
VerificationResult{
236239
ID: doc.Lookup("_id"),
237240
Details: Missing,
@@ -245,7 +248,8 @@ func (verifier *Verifier) compareDocsFromChannels(
245248
})
246249

247250
dstCache.Range(func(_ string, doc bson.Raw) bool {
248-
results = results.Push(
251+
results = append(
252+
results,
249253
VerificationResult{
250254
ID: doc.Lookup("_id"),
251255
Details: Missing,
@@ -258,7 +262,7 @@ func (verifier *Verifier) compareDocsFromChannels(
258262
return true
259263
})
260264

261-
return results.Get(), srcDocCount, srcByteCount, nil
265+
return results, docCount, byteCount, nil
262266
}
263267

264268
func simpleTimerReset(t *time.Timer, dur time.Duration) {

syncslice/syncslice.go

Lines changed: 0 additions & 90 deletions
This file was deleted.

syncslice/unit_test.go

Lines changed: 0 additions & 233 deletions
This file was deleted.

0 commit comments

Comments
 (0)