this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

reuse bufio readers

authored by

whyrusleeping and committed by
whyrusleeping
d021c3ed 62c53346

+13 -1
+13 -1
repo/repo.go
··· 6 6 "context" 7 7 "fmt" 8 8 "io" 9 + "sync" 9 10 10 11 "github.com/bluesky-social/indigo/atproto/repo" 11 12 "github.com/bluesky-social/indigo/atproto/syntax" ··· 77 78 return buf.Bytes(), nil 78 79 } 79 80 81 + var bufrPool = &sync.Pool{ 82 + New: func() any { 83 + return bufio.NewReader(nil) 84 + }, 85 + } 86 + 80 87 func IngestRepo(ctx context.Context, bs cbor.IpldBlockstore, r io.Reader) (cid.Cid, error) { 81 88 ctx, span := otel.Tracer("repo").Start(ctx, "Ingest") 82 89 defer span.End() 83 90 84 - br, root, err := carutil.NewReader(bufio.NewReader(r)) 91 + bufr := bufrPool.Get().(*bufio.Reader) 92 + bufr.Reset(r) 93 + 94 + br, root, err := carutil.NewReader(bufr) 85 95 if err != nil { 86 96 return cid.Undef, fmt.Errorf("opening CAR block reader: %w", err) 87 97 } ··· 99 109 return cid.Undef, fmt.Errorf("copying block to store: %w", err) 100 110 } 101 111 } 112 + 113 + bufrPool.Put(bufr) 102 114 103 115 return root, nil 104 116 }