[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: gzip use of memcpy
From: |
Jim Meyering |
Subject: |
Re: gzip use of memcpy |
Date: |
Mon, 11 Jan 2010 18:32:24 +0100 |
Alain Magloire wrote:
> Bonjour,
>
> Our tester (Yuxi) was proposing something along this line to check for
> overlapping.
>
> ===email from yuxi===
> We could do a smart checking here:
> Unsigned int delta = w > d ? w -d : d -w;
> if (delta >= e) /* (this test assumes unsigned
> comparison) */
> {
> memcpy(slide + w, slide + d, e);
> w += e;
> d += e;
> }
> else /* do it slow to avoid memcpy()
> overlap */
Good idea. Thank you!
How about the patch below?
I realize that it introduces a c99-ism (stmt after decl),
but experience with coreutils has shown that that is no
longer a problem in practice.
>From 17822e2cab5e47d73f224a688be8013c34f990f7 Mon Sep 17 00:00:00 2001
From: Yuxi Zhang <address@hidden>
Date: Mon, 11 Jan 2010 18:28:30 +0100
Subject: [PATCH] gzip -d: use memcpy more often
* inflate.c (inflate_codes): Use memcpy (rather than slower
memcopy-like code) in more cases.
---
inflate.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/inflate.c b/inflate.c
index 5b68314..75353e2 100644
--- a/inflate.c
+++ b/inflate.c
@@ -589,7 +589,8 @@ int bl, bd; /* number of bits decoded by tl[]
and td[] */
do {
n -= (e = (e = WSIZE - ((d &= WSIZE-1) > w ? d : w)) > n ? n : e);
#if !defined(NOMEMCPY) && !defined(DEBUG)
- if (d < w && w - d >= e)
+ unsigned int delta = w > d ? w - d : d - w;
+ if (delta >= e)
{
memcpy(slide + w, slide + d, e);
w += e;
--
1.6.6.511.gf46c4
- gzip use of memcpy, Alain Magloire, 2010/01/06
- Re: gzip use of memcpy, Jim Meyering, 2010/01/08
- RE: gzip use of memcpy, Alain Magloire, 2010/01/08
- RE: gzip use of memcpy, Alain Magloire, 2010/01/08
- Re: gzip use of memcpy, Jim Meyering, 2010/01/10
- RE: gzip use of memcpy, Alain Magloire, 2010/01/11
- Re: gzip use of memcpy,
Jim Meyering <=
- RE: gzip use of memcpy, Yuxi Zhang, 2010/01/11
- Re: gzip use of memcpy, Jim Meyering, 2010/01/12
- RE: gzip use of memcpy, Yuxi Zhang, 2010/01/12
- RE: gzip use of memcpy, Alain Magloire, 2010/01/12