mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rich Felker <dalias@aerifal.cx>
To: musl@lists.openwall.com
Subject: Re: src/string/strstr.c, src/string/wcsstr.c: wrong estimates for MIN(l,63)?
Date: Fri, 21 Mar 2014 13:44:06 -0400	[thread overview]
Message-ID: <20140321174406.GK26358@brightrain.aerifal.cx> (raw)
In-Reply-To: <20140321170745.GC27448@port70.net>

On Fri, Mar 21, 2014 at 06:07:45PM +0100, Szabolcs Nagy wrote:
> * Rich Felker <dalias@aerifal.cx> [2014-03-21 12:48:17 -0400]:
> > On Fri, Mar 21, 2014 at 03:07:22PM +0100, Yves Bastide wrote:
> > > /* Fast estimate for MIN(l,63) */
> > > size_t grow = l | 63;
> > > 
> > > "grow" is thus always at least 63...
> > 
> > If you look at how grow is used on the very next line, this should
> > make sense.
> 
> the comment is wrong though
> z grows by at least max(63,l) unless end-of-string is reached

Yes, (l|63) is >= both l and 63, so it should read MAX, not MIN. The
idea is that it's useless to grow by less than l, but it's inefficient
to grow by less than some fixed threshold even if the needle is tiny.

Rich


  reply	other threads:[~2014-03-21 17:44 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-21 14:07 Yves Bastide
2014-03-21 16:48 ` Rich Felker
2014-03-21 17:07   ` Szabolcs Nagy
2014-03-21 17:44     ` Rich Felker [this message]
2014-03-21 18:10       ` Yves Bastide

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=20140321174406.GK26358@brightrain.aerifal.cx \
    --to=dalias@aerifal.cx \
    --cc=musl@lists.openwall.com \
    /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.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

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).