]> wimlib.net Git - wimlib/blobdiff - include/wimlib/decompress_common.h
lz_copy(): Unroll first iteration
[wimlib] / include / wimlib / decompress_common.h
index da15fd1eef93176e1d34eb616785503cb78d8c4f..3f3742a02ea750aad757febe523109b9441954d6 100644 (file)
@@ -277,13 +277,22 @@ lz_copy(u8 *dst, u32 length, u32 offset, const u8 *winend)
                        unsigned long v;
                } _packed_attribute;
 
-               const u8 *end = dst + length;
-               do {
-                       unsigned long v = ((struct ulong_wrapper *)src)->v;
-                       ((struct ulong_wrapper *)dst)->v = v;
-                       dst += sizeof(unsigned long);
-                       src += sizeof(unsigned long);
-               } while (dst < end);
+               const u8 * const end = dst + length;
+               unsigned long v;
+
+               v = ((struct ulong_wrapper *)src)->v;
+               ((struct ulong_wrapper *)dst)->v = v;
+               dst += sizeof(unsigned long);
+               src += sizeof(unsigned long);
+
+               if (dst < end) {
+                       do {
+                               v = ((struct ulong_wrapper *)src)->v;
+                               ((struct ulong_wrapper *)dst)->v = v;
+                               dst += sizeof(unsigned long);
+                               src += sizeof(unsigned long);
+                       } while (dst < end);
+               }
 
                return;
        }