if (pos < 0) pos = (-pos) - 2; // need one before the insertion point
int startPos = pos;
int endPos = pos;
while (pos + 1 < mapping.length) {
pos++;
Bytes prefix = mapping[pos].getPrefix();
if (! prefix.couldOverlapWith(uncompressed)) break;
endPos = pos;
}
if (startPos != endPos) {
Range range = new Range();
range.setBoundsAndExtractPrefix(compressionLiterals[startPos], compressionLiterals[endPos]);
return range.getPrefix();
}
Bytes prefix = mapping[startPos];
assert prefix.isPrefixOf(uncompressed);
int prefixLen = prefix.getLength();
Bytes suffix = SlicedBytes.make(uncompressed, prefixLen, uncompressedLen - prefixLen);
return CompoundBytes.make(compressionLiterals[pos], suffix);
}