MCPcopy Create free account
hub / github.com/CobaltFusion/DebugViewPP / MaxCompressedLength

Function MaxCompressedLength

Libraries/snappy/snappy.cc:56–78  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

54}
55
56size_t MaxCompressedLength(size_t source_len) {
57 // Compressed data can be defined as:
58 // compressed := item* literal*
59 // item := literal* copy
60 //
61 // The trailing literal sequence has a space blowup of at most 62/60
62 // since a literal of length 60 needs one tag byte + one extra byte
63 // for length information.
64 //
65 // Item blowup is trickier to measure. Suppose the "copy" op copies
66 // 4 bytes of data. Because of a special check in the encoding code,
67 // we produce a 4-byte copy only if the offset is < 65536. Therefore
68 // the copy op takes 3 bytes to encode, and this type of item leads
69 // to at most the 62/60 blowup for representing literals.
70 //
71 // Suppose the "copy" op copies 5 bytes of data. If the offset is big
72 // enough, it will take 5 bytes to encode the copy op. Therefore the
73 // worst case here is a one-byte literal followed by a five-byte copy.
74 // I.e., 6 bytes of input turn into 7 bytes of "compressed" data.
75 //
76 // This last factor dominates the blowup, so the final estimate is:
77 return 32 + source_len + source_len/6;
78}
79
80enum {
81 LITERAL = 0,

Callers 8

CompressFunction · 0.85
VerifyStringFunction · 0.85
VerifyIOVecFunction · 0.85
BM_ZFlatFunction · 0.85
CompressFunction · 0.85

Calls

no outgoing calls

Tested by 6

CompressFunction · 0.68
VerifyStringFunction · 0.68
VerifyIOVecFunction · 0.68
BM_ZFlatFunction · 0.68