Make Attaching an Empty Dict Behave the Same as Using it Directly
authorW. Felix Handte <w@felixhandte.com>
Tue, 6 Aug 2019 19:24:51 +0000 (15:24 -0400)
committerW. Felix Handte <w@felixhandte.com>
Tue, 6 Aug 2019 22:50:33 +0000 (18:50 -0400)
commit918269a4e395d88364a517b889473922ac5521ec
treeffc36dc63f0d0ddeab7bba587cd3df6871f50dda
parentb5b9760c80d70aaa5805c460cb61faad31cbf234
Make Attaching an Empty Dict Behave the Same as Using it Directly

When using an empty dictionary, we bail out of loading or attaching it in
ways that leave the working context in potentially slightly different states.
In particular, in some paths, we will cause the currentOffset to be non-zero,
while in others we would allow it to remain 0.

This difference in behavior is perfectly harmless, but in some situations, it
can produce slight differences in the compressed output. For sanity's sake,
we currently try to maintain a strict correspondence between the behavior of
the dict attachment and the dict loading paths. This patch restores them to
behaving identically.

This shouldn't have any negative side-effects, as far as I can tell. When
writing the dict attachment code, I tried to preserve zeroed currentOffsets
when possible, since they benchmarked as very slightly faster. However, the
case of attaching an empty dictionary is probably rare enought that it's
acceptable to minisculely degrade performance in that corner case.
lib/lz4.c