All of lore.kernel.org
 help / color / mirror / Atom feed
From: Matt Mackall <mpm@selenic.com>
To: Jan Engelhardt <jengelh@computergmbh.de>
Cc: Ingo Oeser <ioe-lkml@rameria.de>,
	lode leroy <lode_leroy@hotmail.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] memchr (trivial) optimization
Date: Fri, 24 Aug 2007 10:57:13 -0500	[thread overview]
Message-ID: <20070824155713.GL21720@waste.org> (raw)
In-Reply-To: <Pine.LNX.4.64.0708241447560.28540@fbirervta.pbzchgretzou.qr>

On Fri, Aug 24, 2007 at 02:54:48PM +0200, Jan Engelhardt wrote:
> 
> On Aug 23 2007 19:13, Matt Mackall wrote:
> >
> >And you can do even better with this:
> >
> >void *memchr(const void *s, int c, size_t n)
> >{
> >       const unsigned char *p = s, *e = s + n;
> >       const unsigned char *e = p + n;
> 
> Uhm, you have two "e"s in there.

Yep, that's what I get for editing in email.

> Or do it glibc-style
> 
> void *memchr(const void *s, unsigned char c, size_t n)
> {
> 	...
> 	for (; p + 3 < e; p += 4) {
> 		if (c == p[0])
> 			return (void *)&p[0];
> 		if (c == p[1])
> 			return (void *)&p[1];
> 		if (c == p[2])
> 			return (void *)&p[2];
> 		if (c == p[3])
> 			return (void *)&p[3];
> 	}
> 	... /* check the rest */
> }

Yes, very funny.

-- 
Mathematics is the supreme nostalgia of our time.

      reply	other threads:[~2007-08-24 15:56 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-08-22  9:34 [PATCH] memchr (trivial) optimization lode leroy
2007-08-22 10:56 ` Andi Kleen
2007-08-23  0:13 ` Ingo Oeser
2007-08-24  0:13   ` Matt Mackall
2007-08-24  1:03     ` Jeremy Fitzhardinge
2007-08-24  2:19       ` Matt Mackall
2007-08-24 12:54     ` Jan Engelhardt
2007-08-24 15:57       ` Matt Mackall [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=20070824155713.GL21720@waste.org \
    --to=mpm@selenic.com \
    --cc=ioe-lkml@rameria.de \
    --cc=jengelh@computergmbh.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lode_leroy@hotmail.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.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.