From owner-freebsd-current@FreeBSD.ORG Wed Apr 6 06:20:45 2005 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 7C7F216A4CE for ; Wed, 6 Apr 2005 06:20:45 +0000 (GMT) Received: from odin.ac.hmc.edu (Odin.AC.HMC.Edu [134.173.32.75]) by mx1.FreeBSD.org (Postfix) with ESMTP id 476C743D45 for ; Wed, 6 Apr 2005 06:20:45 +0000 (GMT) (envelope-from brdavis@odin.ac.hmc.edu) Received: from odin.ac.hmc.edu (localhost.localdomain [127.0.0.1]) by odin.ac.hmc.edu (8.13.0/8.13.0) with ESMTP id j366KiKU004253; Tue, 5 Apr 2005 23:20:44 -0700 Received: (from brdavis@localhost) by odin.ac.hmc.edu (8.13.0/8.13.0/Submit) id j366KhTw004252; Tue, 5 Apr 2005 23:20:43 -0700 Date: Tue, 5 Apr 2005 23:20:43 -0700 From: Brooks Davis To: Matthew Dillon Message-ID: <20050406062043.GB22691@odin.ac.hmc.edu> References: <20050330083435.GI75546@obiwan.tataz.chchile.org> <20050330110613.GB71384@cirb503493.alcatel.com.au> <20050330183145.GB24465@odin.ac.hmc.edu> <200504060346.j363ko4b088610@apollo.backplane.com> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="p4qYPpj5QlsIQJ0K" Content-Disposition: inline In-Reply-To: <200504060346.j363ko4b088610@apollo.backplane.com> User-Agent: Mutt/1.4.1i X-Virus-Scanned: by amavisd-new X-Spam-Status: No, hits=0.0 required=8.0 tests=none autolearn=no version=2.63 X-Spam-Checker-Version: SpamAssassin 2.63 (2004-01-11) on odin.ac.hmc.edu cc: Peter Jeremy cc: freebsd-current@freebsd.org cc: Jeremie Le Hen Subject: Re: strcspn(3) complexity improvement X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 06 Apr 2005 06:20:45 -0000 --p4qYPpj5QlsIQJ0K Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Apr 05, 2005 at 08:46:50PM -0700, Matthew Dillon wrote: > :The real question I have is, how long does the string need to be before > :this is a win and how much does it hurt for typical string lengths? > :I've written code with strcspn that needed to perform well, but it was > :parsing 80-column punch card derived formats. >=20 > I think the answer is to not use strcspn() in cases where it *really* > matters. Certainly. strcspn() wasn't worth optimizing out after I replaced the hand coded crap that used getc to parse files up to 100MB is size and did a realloc for each character! That got me a 50% speedup in overall execution time and the function dropped from #1 to <#50 in the profiling numbers. At that point FPU intensive code was at the top where it belonged. My main point was to avoid a purely theoretical "optimization". -- Brooks --=20 Any statement of the form "X is the one, true Y" is FALSE. PGP fingerprint 655D 519C 26A7 82E7 2529 9BF0 5D8E 8BE9 F238 1AD4 --p4qYPpj5QlsIQJ0K Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.1 (GNU/Linux) iD8DBQFCU3+yXY6L6fI4GtQRAo3cAKCjGIbjiZbYPuBrUDMBmlq8s9UbqgCaAj8u PMXZq4cqToA2dCnZ7RUy2E0= =fV/5 -----END PGP SIGNATURE----- --p4qYPpj5QlsIQJ0K--