From: Tor Myklebust <tmyklebu@csclub.uwaterloo.ca>
To: Christian Thaeter <ct@pipapo.org>
Cc: libc-alpha@sourceware.org, git@vger.kernel.org
Subject: Re: memmem.c improvement
Date: Fri, 30 Nov 2007 22:07:01 -0500 (EST) [thread overview]
Message-ID: <Pine.LNX.4.64.0711302151340.9426@caffeine.csclub.uwaterloo.ca> (raw)
In-Reply-To: <4750C74B.8060308@pipapo.org>
On Sat, 1 Dec 2007, Christian Thaeter wrote:
> I am fully aware that this is not the best possible search algorithm.
> It is considerably better than the actual one for 'common' data.
And not considerably worse in the worst case I could think of. (Which was
my point, not that it was slow or sucked in some other way.)
> Having a string with few symbols or other corner cases needs an
> algorithm better suited for that task.
Yes, if it's actually worth anyone's time making strstr() fast in the case
where the haystack has length three and the needle length two.
Amusingly enough, I haven't ever seen strstr() used to do any nontrivial
string matching in any free software I've bothered to grep.
> But well, this was just reaching a low hanging fruit.
Suitably hacked, your code looks clearly correct. But there are valid
reasons not to mess with the strstr() in libc (fewer for memmem()); chief
among them is that *if* there is an undetected bug in the code, *then*
lots of stuff can break.
> For me it suffices and I won't put more efforts into improving or
> lobbying it, its just not worth it.
Clearly, the tone of my email did not help convey my message. (Perhaps I
should just stop trying to write words of encouragement altogether --- it
never goes according to plan and always seems to end in disaster.) I do
commend you for submitting improvements (and this is clearly an
improvement); I was merely trying to point out that it will likely be an
uphill battle, and that certain things are either wrong or can be done
better than you have done. Do go on, please! (And I'm sorry if my
previous email caused you particular dismay.)
Tor Myklebust
prev parent reply other threads:[~2007-12-01 3:07 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-12-01 0:48 memmem.c improvement Christian Thaeter
2007-12-01 1:58 ` (class=ham score=-4.96032) " Tor Myklebust
2007-12-01 2:30 ` Christian Thaeter
2007-12-01 3:07 ` Tor Myklebust [this message]
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=Pine.LNX.4.64.0711302151340.9426@caffeine.csclub.uwaterloo.ca \
--to=tmyklebu@csclub.uwaterloo.ca \
--cc=ct@pipapo.org \
--cc=git@vger.kernel.org \
--cc=libc-alpha@sourceware.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).