Skip to content
This repository was archived by the owner on Jun 19, 2023. It is now read-only.

Commit e4da93c

Browse files
authored
feat: fast-path for PutMany, falling back to Put for single block call (#97)
1 parent f5e3cdb commit e4da93c

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

blockstore.go

+5
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,11 @@ func (bs *blockstore) Put(ctx context.Context, block blocks.Block) error {
178178
}
179179

180180
func (bs *blockstore) PutMany(ctx context.Context, blocks []blocks.Block) error {
181+
if len(blocks) == 1 {
182+
// performance fast-path
183+
return bs.Put(ctx, blocks[0])
184+
}
185+
181186
t, err := bs.datastore.Batch(ctx)
182187
if err != nil {
183188
return err

0 commit comments

Comments
 (0)