// Returns an "end" pointer into "op" buffer.
// "end - op" is the compressed size of "input".
namespace internal {
-char* CompressFragment(const char* const input,
- const size_t input_size,
+char* CompressFragment(const char* input,
+ size_t input_size,
char* op,
uint16* table,
const int table_size) {
}
const unsigned char c = *(reinterpret_cast<const unsigned char*>(ip++));
- const uint32 entry = char_table[c];
- const uint32 trailer = LittleEndian::Load32(ip) & wordmask[entry >> 11];
- ip += entry >> 11;
- const uint32 length = entry & 0xff;
if ((c & 0x3) == LITERAL) {
- uint32 literal_length = length + trailer;
+ uint32 literal_length = c >> 2;
+ if (PREDICT_FALSE(literal_length >= 60)) {
+ // Long literal.
+ const uint32 literal_length_length = literal_length - 59;
+ literal_length =
+ LittleEndian::Load32(ip) & wordmask[literal_length_length];
+ ip += literal_length_length;
+ }
+ ++literal_length;
+
uint32 avail = ip_limit_ - ip;
while (avail < literal_length) {
- bool allow_fast_path = (avail >= 16);
- if (!writer->Append(ip, avail, allow_fast_path)) return;
+ if (!writer->Append(ip, avail, false)) return;
literal_length -= avail;
reader_->Skip(peeked_);
size_t n;
}
ip += literal_length;
} else {
+ const uint32 entry = char_table[c];
+ const uint32 trailer = LittleEndian::Load32(ip) & wordmask[entry >> 11];
+ const uint32 length = entry & 0xff;
+ ip += entry >> 11;
+
// copy_offset/256 is encoded in bits 8..10. By just fetching
// those bits, we get copy_offset (since the bit-field starts at
// bit 8).