Skip to content

Commit

Permalink
chore[protocol]: deep clone log
Browse files Browse the repository at this point in the history
  • Loading branch information
jaysunxiao committed Jul 29, 2024
1 parent 7c58329 commit 04d4815
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions protocol/src/main/resources/php/ByteBuffer.php
Original file line number Diff line number Diff line change
@@ -32,6 +32,7 @@ public function adjustPadding(int $predictionLength, int $beforewriteIndex): voi
$this->writeInt($length);
$this->writeOffset = $currentwriteIndex;
} else {
// substr is deep clone
$bytes = substr($this->buffer, $currentwriteIndex - $length, $length);
$this->writeOffset = $beforewriteIndex;
$this->writeInt($length);
1 change: 1 addition & 0 deletions protocol/src/main/resources/python/ByteBuffer.py
Original file line number Diff line number Diff line change
@@ -25,6 +25,7 @@ def adjustPadding(self, predictionLength, beforeWriteIndex):
self.writeInt(length)
self.setWriteOffset(currentWriteIndex)
else:
# slice of bytearray is deep clone
retainedByteBuf = self.buffer[(currentWriteIndex - length):currentWriteIndex]
self.setWriteOffset(beforeWriteIndex)
self.writeInt(length)

0 comments on commit 04d4815

Please sign in to comment.