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); }