From owner-freebsd-current@FreeBSD.ORG Wed Apr 6 03:46:51 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 19BF416A4CF for ; Wed, 6 Apr 2005 03:46:51 +0000 (GMT) Received: from apollo.backplane.com (apollo.backplane.com [216.240.41.2]) by mx1.FreeBSD.org (Postfix) with ESMTP id CA91E43D49 for ; Wed, 6 Apr 2005 03:46:50 +0000 (GMT) (envelope-from dillon@apollo.backplane.com) Received: from apollo.backplane.com (localhost [127.0.0.1]) j363ko0e088611; Tue, 5 Apr 2005 20:46:50 -0700 (PDT) (envelope-from dillon@apollo.backplane.com) Received: (from dillon@localhost) by apollo.backplane.com (8.12.9p2/8.12.9/Submit) id j363ko4b088610; Tue, 5 Apr 2005 20:46:50 -0700 (PDT) (envelope-from dillon) Date: Tue, 5 Apr 2005 20:46:50 -0700 (PDT) From: Matthew Dillon Message-Id: <200504060346.j363ko4b088610@apollo.backplane.com> To: Brooks Davis References: <20050330083435.GI75546@obiwan.tataz.chchile.org> <20050330183145.GB24465@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 03:46:51 -0000 :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. : :-- Brooks I think the answer is to not use strcspn() in cases where it *really* matters. I don't think what's in DFly is the right solution either. A bitmap would be a good compromise, though... that would only require clearing 32 bytes (vs 256) at the cost of slowing down the loop a little. -Matt Matthew Dillon