sS decompressMozillaJSONLZ4File(File f) {
byte[] data = loadBinaryFile(f);
if (empty(data)) null;
int lDecompressed = intFromBytes_littleEndian(data, 8);
// our very own LZ4 decompressor!
int i = 12, n = l(data), iOut = 0;
byte[] out = new byte[lDecompressed];
while (i < n) {
int lLiteral = (data[i] >> 4) & 0x0F;
int lMatches = (data[i] & 0x0F)+4;
i++;
if (lLiteral == 15) {
int more;
do {
more = data[i++] & 0xFF;
lLiteral += more;
} while (more == 255);
}
arraycopy(data, i, out, iOut, lLiteral);
iOut += lLiteral;
i += lLiteral;
if (i >= n) break;
int offset = data[i] & 0xFF | (data[i+1] & 0xFF) << 8;
i += 2;
if (offset == 0) fail("bad offset");
if (lMatches == 19) {
int more;
do {
more = data[i++] & 0xFF;
lMatches += more;
} while (more == 255);
}
int j = lMatches;
while (j-- > 0) {
out[iOut] = out[iOut-offset];
iOut++;
}
}
ret fromUtf8(out);
}Began life as a copy of #1019807
download show line numbers debug dex old transpilations
Travelled to 9 computer(s): bhatertpkbcr, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
| Snippet ID: | #1019811 |
| Snippet name: | decompressMozillaJSONLZ4File |
| Eternal ID of this version: | #1019811/1 |
| Text MD5: | 3add850dfee3b23296469bf93db66ba6 |
| Author: | stefan |
| Category: | javax / lz4 |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2018-11-26 23:50:00 |
| Source code size: | 1067 bytes / 42 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 757 / 763 |
| Referenced in: | [show references] |