Subject: PR/36092 CVS commit: src/bin/test
To: None <gnats-admin@netbsd.org, netbsd-bugs@netbsd.org,>
From: Christos Zoulas <christos@netbsd.org>
List: netbsd-bugs
Date: 03/28/2007 01:50:02
The following reply was made to PR bin/36092; it has been noted by GNATS.

From: Christos Zoulas <christos@netbsd.org>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: PR/36092 CVS commit: src/bin/test
Date: Wed, 28 Mar 2007 01:47:26 +0000 (UTC)

 Module Name:	src
 Committed By:	christos
 Date:		Wed Mar 28 01:47:26 UTC 2007
 
 Modified Files:
 	src/bin/test: test.c
 
 Log Message:
 PR/36092: B K: algorithmic inefficiency in bin/test/test.c:t_lex
 test(1) scans for "operators" linearly in an array using strcmp() to
 find a match. Since the list of "operators" is fixed, split them
 into one and two character ones, and ones that start with a `-' and
 ones they don't. This way we can optimize the compare function to
 just check for one or two characters. Sort and use bsearch(3). We
 could have used a single sorted array and bsearch(3), to save some
 complexity, but I decided to be a bit fancier.
 
 
 To generate a diff of this commit:
 cvs rdiff -r1.30 -r1.31 src/bin/test/test.c
 
 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.