Skip to content

Commit

Permalink
Reduce ArrayUtil#grow in decompress (#12996)
Browse files Browse the repository at this point in the history
  • Loading branch information
easyice authored and vigyasharma committed Apr 9, 2024
1 parent 1edda10 commit 7ef18f2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 2 additions & 0 deletions lucene/CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ Improvements
Optimizations
---------------------

* GITHUB#12996: Reduce ArrayUtil#grow in decompress. (Zhang Chao)

* GITHUB#13115: Short circuit queued flush check when flush on update is disabled (Prabhat Sharma)

* GITHUB#13085: Remove unnecessary toString() / substring() calls to save some String allocations (Dmitry Cherniachenko)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,12 @@ public void decompress(DataInput in, int originalLength, int offset, int length,
}

// Read blocks that intersect with the interval we need
if (offsetInBlock < offset + length) {
bytes.bytes = ArrayUtil.grow(bytes.bytes, bytes.length + offset + length - offsetInBlock);
}
while (offsetInBlock < offset + length) {
final int bytesToDecompress = Math.min(blockLength, offset + length - offsetInBlock);
LZ4.decompress(in, bytesToDecompress, buffer, dictLength);
bytes.bytes = ArrayUtil.grow(bytes.bytes, bytes.length + bytesToDecompress);
System.arraycopy(buffer, dictLength, bytes.bytes, bytes.length, bytesToDecompress);
bytes.length += bytesToDecompress;
offsetInBlock += blockLength;
Expand Down

0 comments on commit 7ef18f2

Please sign in to comment.