Skip to content

Commit 3a5d0f3

Browse files
committed
roachpb: avoid an allocation NewConditionalPut
1 parent 6217723 commit 3a5d0f3

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

roachpb/api.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -667,7 +667,9 @@ func NewConditionalPut(key Key, value, expValue Value) Request {
667667
value.InitChecksum(key)
668668
var expValuePtr *Value
669669
if expValue.RawBytes != nil {
670-
expValuePtr = &expValue
670+
// Make a copy to avoid forcing expValue itself on to the heap.
671+
expValueTmp := expValue
672+
expValuePtr = &expValueTmp
671673
expValue.InitChecksum(key)
672674
}
673675
return &ConditionalPutRequest{

0 commit comments

Comments
 (0)