init ua parser once (#3883)

This commit is contained in:
Paul Wells
2025-08-28 05:20:25 -07:00
committed by GitHub
parent 998a9f9404
commit 2aeadf14dc
3 changed files with 23 additions and 8 deletions
+4 -4
View File
@@ -177,15 +177,15 @@ func ChunkProtoBatch[T proto.Message](batch []T, target int) [][]T {
var chunks [][]T
var start, size int
for i, m := range batch {
if s := proto.Size(m); size+s > target {
s := proto.Size(m)
if size+s > target {
if start < i {
chunks = append(chunks, batch[start:i])
}
start = i
size = s
} else {
size += s
size = 0
}
size += s
}
if start < len(batch) {
chunks = append(chunks, batch[start:])