Skip to content

Commit

Permalink
Remove unneccessary ArrayUtil.grow in Zstd compression modes. (#121) (#…
Browse files Browse the repository at this point in the history
…123)

(cherry picked from commit be53471)

Signed-off-by: Mulugeta Mammo <mulugeta.mammo@intel.com>
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
1 parent c2fbdde commit 574fac2
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,6 @@ public void decompress(DataInput in, int originalLength, int offset, int length,

// Read blocks that intersect with the interval we need
while (offsetInBlock < offset + length) {
bytes.bytes = ArrayUtil.grow(bytes.bytes, bytes.length + blockLength);
int l = Math.min(blockLength, originalLength - offsetInBlock);
doDecompress(in, dctx, bytes, l);
offsetInBlock += blockLength;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,6 @@ public void decompress(DataInput in, int originalLength, int offset, int length,

// Read blocks that intersect with the interval we need
while (offsetInBlock < offset + length) {
bytes.bytes = ArrayUtil.grow(bytes.bytes, bytes.length + blockLength);
final int compressedLength = in.readVInt();
if (compressedLength == 0) {
return;
Expand All @@ -159,10 +158,7 @@ public void decompress(DataInput in, int originalLength, int offset, int length,
int l = Math.min(blockLength, originalLength - offsetInBlock);
bytes.bytes = ArrayUtil.grow(bytes.bytes, bytes.length + l);

byte[] output = new byte[l];

final int uncompressed = (int) Zstd.decompressByteArray(output, 0, l, compressed, 0, compressedLength);
System.arraycopy(output, 0, bytes.bytes, bytes.length, uncompressed);
final int uncompressed = (int) Zstd.decompressByteArray(bytes.bytes, bytes.length, l, compressed, 0, compressedLength);

bytes.length += uncompressed;
offsetInBlock += blockLength;
Expand Down

0 comments on commit 574fac2

Please sign in to comment.