From: Paul Mackerras <paulus@samba.org>
To: "Jörn Engel" <joern@wohnheim.fh-wedel.de>
Cc: joakim.tjernlund@lumentis.se,
"Linuxppc-Dev@Lists. Linuxppc. Org"
<linuxppc-dev@lists.linuxppc.org>
Subject: Re: memmove broken
Date: Sat, 5 Jul 2003 23:01:15 +1000 [thread overview]
Message-ID: <16134.52251.943207.814024@cargo.ozlabs.ibm.com> (raw)
In-Reply-To: <20030705072119.GA32363@wohnheim.fh-wedel.de>
Jörn Engel writes:
> > Why is it an issue? Is the performance of the byte-by-byte loop
> > really a limiting factor for you?
>
> Not a limiting factor, but it should be noticable. What is more
> important - in my eyes - is that we can replace magic with obvious
> code.
You are proposing to replace simple, working code with considerably
more complex code. You need to be able to point to a specific real
situation where your change makes a significant difference if you want
to get it accepted.
If the behaviour of the copy loop is non-obvious then the thing to do
is to add a comment rather than make it more complicated.
> That should not be a problem. memcpy has a very defined behaviour, as
> long as source and destination don't overlap at all or as the sourse
> is smaller, than the distination. Cool.
The behaviour is defined as long as source and destination don't
overlap. You get no guarantees from having source < destination. It
could quite legitimately copy backwards in all situations, or work
exactly the same as memmove.
> We should be able to do something like this in the zlib:
> if (repeat one byte over and over) /* undefined behaviour for memcpy */
> memset();
> else {
> if (copy is wrapped) {
> memcpy(wrapped part);
> tweak pointers;
> }
> memcpy();
>
> With that, source should always be smaller than destination for
> memcpy, so the implementation details don't matter, as long as memcpy
> doesn't do a reverse memcpy.
>
> Plus, the zlib code is shorter and tells the reader exactly what it
> does, without the need for extra comments.
Well no, I think it still isn't right. What if the length is large
but dst - src == 2 (e.g. if you compress "abababababab") or 3 (e.g. if
you compress "abcabcabcabcabc")? Or 4 or 5 or ...? You will end up
with an awfully large number of special cases.
Paul.
** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/
next prev parent reply other threads:[~2003-07-05 13:01 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-07-03 17:20 memmove broken Joakim Tjernlund
2003-07-04 6:17 ` Paul Mackerras
2003-07-04 8:32 ` Joakim Tjernlund
2003-07-04 9:37 ` Paul Mackerras
2003-07-04 11:07 ` Joakim Tjernlund
2003-07-04 23:38 ` Paul Mackerras
2003-07-05 7:21 ` Jörn Engel
2003-07-05 9:55 ` Holger Bettag
2003-07-05 13:01 ` Paul Mackerras [this message]
2003-07-05 14:57 ` Joakim Tjernlund
2003-07-05 17:01 ` Jörn Engel
2003-07-07 10:32 ` Joakim Tjernlund
2003-07-07 12:06 ` Jörn Engel
2003-07-07 12:58 ` Joakim Tjernlund
2003-07-07 13:16 ` Jörn Engel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=16134.52251.943207.814024@cargo.ozlabs.ibm.com \
--to=paulus@samba.org \
--cc=joakim.tjernlund@lumentis.se \
--cc=joern@wohnheim.fh-wedel.de \
--cc=linuxppc-dev@lists.linuxppc.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).