unlzma: expand comments, no code changes
authorDenys Vlasenko <vda.linux@googlemail.com>
Mon, 9 Jan 2017 13:28:25 +0000 (14:28 +0100)
committerDenys Vlasenko <vda.linux@googlemail.com>
Mon, 9 Jan 2017 13:28:25 +0000 (14:28 +0100)
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
archival/libarchive/decompress_unlzma.c

index 90a428583736b10fee5002c740115a3da67a3105..a9040877efa09d1c54082ef6f81e945c2d5e91e7 100644 (file)
@@ -432,6 +432,21 @@ unpack_lzma_stream(transformer_state_t *xstate)
                        }
 
                        len += LZMA_MATCH_MIN_LEN;
+                       /*
+                        * LZMA SDK has this optimized:
+                        * it precalculates size and copies many bytes
+                        * in a loop with simpler checks, a-la:
+                        *      do
+                        *              *(dest) = *(dest + ofs);
+                        *      while (++dest != lim);
+                        * and
+                        *      do {
+                        *              buffer[buffer_pos++] = buffer[pos];
+                        *              if (++pos == header.dict_size)
+                        *                      pos = 0;
+                        *      } while (--cur_len != 0);
+                        * Our code is slower (more checks per byte copy):
+                        */
  IF_NOT_FEATURE_LZMA_FAST(string:)
                        do {
                                uint32_t pos = buffer_pos - rep0;
@@ -451,6 +466,9 @@ unpack_lzma_stream(transformer_state_t *xstate)
                        } while (len != 0 && buffer_pos < header.dst_size);
                        /* FIXME: ...........^^^^^
                         * shouldn't it be "global_pos + buffer_pos < header.dst_size"?
+                        * It probably should, but it is a "do we accidentally
+                        * unpack more bytes than expected?" check - which
+                        * never happens for well-formed compression data...
                         */
                }
        }