diff options
author | Snappy Team <no-reply@google.com> | 2020-01-31 09:44:03 +0000 |
---|---|---|
committer | Victor Costan <costan@google.com> | 2020-04-11 04:40:09 +0000 |
commit | cddd9c0875e55c9c212802b0fc8082d5b3889edd (patch) | |
tree | 84c8888bb95b9caa8619322cc0a1e44de38dccea | |
parent | 537f4ad6240e586970fe554614542e9717df7902 (diff) | |
download | snappy-git-cddd9c0875e55c9c212802b0fc8082d5b3889edd.tar.gz |
Improve comments in IncrementalCopy, add an assert.
PiperOrigin-RevId: 292506754
-rw-r--r-- | snappy.cc | 9 |
1 files changed, 6 insertions, 3 deletions
@@ -190,9 +190,12 @@ inline char* IncrementalCopy(const char* src, char* op, char* const op_limit, assert(src < op); assert(op <= op_limit); assert(op_limit <= buf_limit); - // NOTE: The compressor always emits 4 <= len <= 64. It is ok to assume that - // to optimize this function but we have to also handle other cases in case - // the input does not satisfy these conditions. + // NOTE: The copy tags use 3 or 6 bits to store the copy length, so len <= 64. + assert(op_limit - op <= 64); + // NOTE: In practice the compressor always emits len >= 4, so it is ok to + // assume that to optimize this function, but this is not guaranteed by the + // compression format, so we have to also handle len < 4 in case the input + // does not satisfy these conditions. size_t pattern_size = op - src; // The cases are split into different branches to allow the branch predictor, |