Skip to content

Commit

Permalink
compact: save the resized valueBuf when saving values
Browse files Browse the repository at this point in the history
Previously saveValue would copy the current iteration value into valueBuf, but
if valueBuf was grown to accommodate a larger value, valueBuf wasn't stored.
This lead to repeated re-allocations of buffers sufficiently large to hold the
iteration value.
  • Loading branch information
jbowens committed Jan 11, 2025
1 parent ce9b648 commit 38fb051
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion internal/compact/iterator.go
Original file line number Diff line number Diff line change
Expand Up @@ -1294,7 +1294,8 @@ func (i *Iter) saveValue() {
i.err = err
i.value = base.LazyValue{}
} else if !callerOwned {
i.value = base.MakeInPlaceValue(append(i.valueBuf[:0], v...))
i.valueBuf = append(i.valueBuf[:0], v...)
i.value = base.MakeInPlaceValue(i.valueBuf)
} else {
i.value = base.MakeInPlaceValue(v)
}
Expand Down

0 comments on commit 38fb051

Please sign in to comment.