Skip to content

Commit 285d94f

Browse files
committed
better
1 parent 2d0a2d9 commit 285d94f

File tree

4 files changed

+3
-7
lines changed

4 files changed

+3
-7
lines changed

source.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,6 @@ func (s *Source) Open(ctx context.Context, pos opencdc.Position) error {
120120
}
121121

122122
func (s *Source) ReadN(ctx context.Context, n int) ([]opencdc.Record, error) {
123-
if n <= 0 {
124-
return []opencdc.Record{}, nil
125-
}
126-
127123
return s.iterator.NextN(ctx, n)
128124
}
129125

source/logrepl/cdc_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,7 @@ func TestCDCIterator_NextN(t *testing.T) {
510510
}
511511

512512
// Will keep calling NextN until all records are received
513-
var records []opencdc.Record
513+
records := make([]opencdc.Record, 0, 2)
514514
for len(records) < 2 {
515515
recordsTmp, err := i.NextN(ctx, 5)
516516
is.NoErr(err)

source/logrepl/combined_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ func TestCombinedIterator_NextN(t *testing.T) {
289289
is.NoErr(err)
290290

291291
// Request 2 records in CDC mode
292-
var records []opencdc.Record
292+
records := make([]opencdc.Record, 0, 2)
293293
var retries int
294294
maxRetries := 10
295295
for retries < maxRetries {

source/snapshot/iterator.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ func (i *Iterator) NextN(ctx context.Context, n int) ([]opencdc.Record, error) {
8787
return nil, fmt.Errorf("n must be greater than 0, got %d", n)
8888
}
8989

90-
var records []opencdc.Record
90+
records := make([]opencdc.Record, 0, n)
9191

9292
// Get first record (blocking)
9393
select {

0 commit comments

Comments
 (0)