summaryrefslogtreecommitdiff
path: root/lzf_c.c
diff options
context:
space:
mode:
authorroot <root>2007-06-21 22:11:34 +0000
committerroot <root>2007-06-21 22:11:34 +0000
commit3abfcd994a7dad841f223bb64bd74fb59d13fef2 (patch)
tree1f0da4493c9d60ef30858bac6491556a00e71783 /lzf_c.c
parent4e5f1e7cb11f71bcc35be6babc6a3ba037e5b5b8 (diff)
*** empty log message ***
Diffstat (limited to 'lzf_c.c')
-rw-r--r--lzf_c.c30
1 files changed, 21 insertions, 9 deletions
diff --git a/lzf_c.c b/lzf_c.c
index f65ad72..216a4d9 100644
--- a/lzf_c.c
+++ b/lzf_c.c
@@ -72,6 +72,13 @@
#define MAX_OFF (1 << 13)
#define MAX_REF ((1 << 8) + (1 << 3))
+#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
+
/*
* compressed format
*
@@ -104,11 +111,10 @@ lzf_compress (const void *const in_data, unsigned int in_len,
int lit = 0;
#if INIT_HTAB
-# if USE_MEMCPY
- memset (htab, 0, sizeof (htab));
-# else
- for (hslot = htab; hslot < htab + HSIZE; hslot++)
- *hslot++ = ip;
+ memset (htab, 0, sizeof (htab));
+# if 0
+ for (hslot = htab; hslot < htab + HSIZE; hslot++)
+ *hslot++ = ip;
# endif
#endif
@@ -214,10 +220,10 @@ lzf_compress (const void *const in_data, unsigned int in_len,
return 0;
*op++ = MAX_LIT - 1;
-#if USE_MEMCPY
- memcpy (op, ip - MAX_LIT, MAX_LIT);
- op += MAX_LIT;
- lit = 0;
+
+#ifdef lzf_movsb
+ ip -= lit;
+ lzf_movsb (op, ip, lit);
#else
lit = -lit;
do
@@ -233,11 +239,17 @@ lzf_compress (const void *const in_data, unsigned int in_len,
return 0;
*op++ = lit - 1;
+#ifdef lzf_movsb
+ ip -= lit;
+ lzf_movsb (op, ip, lit);
+#else
lit = -lit;
do
*op++ = ip[lit];
while (++lit);
+#endif
}
return op - (u8 *) out_data;
}
+