summaryrefslogtreecommitdiff
path: root/lzf_d.c
diff options
context:
space:
mode:
Diffstat (limited to 'lzf_d.c')
-rw-r--r--lzf_d.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/lzf_d.c b/lzf_d.c
index 73a1a80..61df183 100644
--- a/lzf_d.c
+++ b/lzf_d.c
@@ -45,6 +45,13 @@
# define SET_ERRNO(n) errno = (n)
#endif
+#if (__i386 || __amd64) && __GNUC__ >= 3
+# define lzf_movsb(dst, src, len) \
+ asm ("rep movsb" \
+ : "=D" (dst), "=S" (src), "=c" (len) \
+ : "0" (dst), "1" (src), "2" (len));
+#endif
+
unsigned int
lzf_decompress (const void *const in_data, unsigned int in_len,
void *out_data, unsigned int out_len)
@@ -76,10 +83,8 @@ lzf_decompress (const void *const in_data, unsigned int in_len,
}
#endif
-#if USE_MEMCPY
- memcpy (op, ip, ctrl);
- op += ctrl;
- ip += ctrl;
+#ifdef lzf_movsb
+ lzf_movsb (op, ip, ctrl);
#else
do
*op++ = *ip++;
@@ -125,12 +130,17 @@ lzf_decompress (const void *const in_data, unsigned int in_len,
return 0;
}
+#ifdef lzf_movsb
+ len += 2;
+ lzf_movsb (op, ref, len);
+#else
*op++ = *ref++;
*op++ = *ref++;
do
*op++ = *ref++;
while (--len);
+#endif
}
}
while (ip < in_end);