Skip to content

Commit

Permalink
only set zero if necessary
Browse files Browse the repository at this point in the history
  • Loading branch information
ViggoC committed Nov 5, 2024
1 parent 76f3fc1 commit de5a74d
Showing 1 changed file with 6 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1367,10 +1367,6 @@ protected ArrowBuf allocateOrGetLastDataBuffer(int length) {
protected final void setBytes(int index, byte[] value, int start, int length) {
int writePosition = index * ELEMENT_SIZE;

// to clear the memory segment of view being written to
// this is helpful in case of overwriting the value
viewBuffer.setZero(writePosition, ELEMENT_SIZE);

if (length <= INLINE_SIZE) {
// allocate inline buffer
// set length
Expand Down Expand Up @@ -1411,11 +1407,13 @@ protected final void setBytes(int index, byte[] value, int start, int length) {
protected final void setBytes(int index, ArrowBuf valueBuf, int start, int length) {
int writePosition = index * ELEMENT_SIZE;

// to clear the memory segment of view being written to
// this is helpful in case of overwriting the value
viewBuffer.setZero(writePosition, ELEMENT_SIZE);

if (length <= INLINE_SIZE) {
// to clear the memory segment of view being written to
// if it has been set
if (viewBuffer.getLong(writePosition) != 0 || viewBuffer.getLong(writePosition + 8) != 0) {
viewBuffer.setZero(writePosition, ELEMENT_SIZE);
}

// allocate inline buffer
// set length
viewBuffer.setInt(writePosition, length);
Expand Down

0 comments on commit de5a74d

Please sign in to comment.