lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Pine.LNX.4.64.0708241447560.28540@fbirervta.pbzchgretzou.qr>
Date:	Fri, 24 Aug 2007 14:54:48 +0200 (CEST)
From:	Jan Engelhardt <jengelh@...putergmbh.de>
To:	Matt Mackall <mpm@...enic.com>
cc:	Ingo Oeser <ioe-lkml@...eria.de>,
	lode leroy <lode_leroy@...mail.com>,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH] memchr (trivial) optimization


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.

>       for (; p < e ; p++)
>                if ((unsigned char)c == *p)
>                        return (void *)p;
>
>       return NULL;
>}

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 */
}


	Jan
-- 
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ