From owner-freebsd-current@FreeBSD.ORG Sun Aug 22 16:36:45 2010 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C7226106567A; Sun, 22 Aug 2010 16:36:45 +0000 (UTC) (envelope-from ed@hoeg.nl) Received: from mx0.hoeg.nl (unknown [IPv6:2a01:4f8:101:5343::aa]) by mx1.freebsd.org (Postfix) with ESMTP id 65AA98FC14; Sun, 22 Aug 2010 16:36:45 +0000 (UTC) Received: by mx0.hoeg.nl (Postfix, from userid 1000) id C5C462A28D21; Sun, 22 Aug 2010 18:36:44 +0200 (CEST) Date: Sun, 22 Aug 2010 18:36:44 +0200 From: Ed Schouten To: Mike Haertel Message-ID: <20100822163644.GU2978@hoeg.nl> References: <201008210231.o7L2VRvI031700@ducky.net> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="Zu4V1sHRt6IpqgDQ" Content-Disposition: inline In-Reply-To: <201008210231.o7L2VRvI031700@ducky.net> User-Agent: Mutt/1.5.20 (2009-06-14) Cc: freebsd-current@freebsd.org, gabor@freebsd.org Subject: Re: why GNU grep is fast X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 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: Sun, 22 Aug 2010 16:36:45 -0000 --Zu4V1sHRt6IpqgDQ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable * Mike Haertel wrote: > Moreover, GNU grep AVOIDS BREAKING THE INPUT INTO LINES. Looking > for newlines would slow grep down by a factor of several times, > because to find the newlines it would have to look at every byte! I think that implementing a simple fgrep boils down to mmap()ing a file and calling memmem() on the mapping to search for the input string. Of course this relies on having an efficient memmem() implementation, for example using one of the algorithms mentioned in this thread. --=20 Ed Schouten WWW: http://80386.nl/ --Zu4V1sHRt6IpqgDQ Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.16 (FreeBSD) iEYEARECAAYFAkxxUhwACgkQ52SDGA2eCwUZkQCcDc4rDxdk9c9GEH8duXUt42Vc g4EAnRCjEnYVt9eS8tvuE0if6BWUUFOw =yYgr -----END PGP SIGNATURE----- --Zu4V1sHRt6IpqgDQ--