git: d43255b50c2b - main - remove dead code

From: Wolfram Schneider <wosch_at_FreeBSD.org>
Date: Thu, 03 Feb 2022 17:03:23 UTC
The branch main has been updated by wosch:

URL: https://cgit.FreeBSD.org/src/commit/?id=d43255b50c2bfb00452d0b2f0edafb8a38cf79b3

commit d43255b50c2bfb00452d0b2f0edafb8a38cf79b3
Author:     Wolfram Schneider <wosch@FreeBSD.org>
AuthorDate: 2022-02-03 17:02:37 +0000
Commit:     Wolfram Schneider <wosch@FreeBSD.org>
CommitDate: 2022-02-03 17:02:37 +0000

    remove dead code
    
    A lookup array is faster than a function with linear search.
    The old function was not used for years - spring cleaning.
---
 usr.bin/locate/code/locate.code.c | 37 ++-----------------------------------
 1 file changed, 2 insertions(+), 35 deletions(-)

diff --git a/usr.bin/locate/code/locate.code.c b/usr.bin/locate/code/locate.code.c
index 5263d9ee8fb0..f352cb2e6f6e 100644
--- a/usr.bin/locate/code/locate.code.c
+++ b/usr.bin/locate/code/locate.code.c
@@ -106,20 +106,12 @@ u_char buf1[LOCATE_PATH_MAX] = " ";
 u_char buf2[LOCATE_PATH_MAX];
 u_char bigrams[BGBUFSIZE + 1] = { 0 };
 
-#define LOOKUP 1 /* use a lookup array instead a function, 3x faster */
-
-#ifdef LOOKUP
+/* use a lookup array instead a function, 3x faster than linear search */
 #define BGINDEX(x) (big[(u_char)*x][(u_char)*(x + 1)])
 typedef short bg_t;
 bg_t big[UCHAR_MAX + 1][UCHAR_MAX + 1];
-#else
-#define BGINDEX(x) bgindex(x)
-typedef int bg_t;
-int	bgindex(char *);
-#endif /* LOOKUP */
-
 
-void	usage(void);
+void   usage(void);
 
 int
 main(int argc, char *argv[])
@@ -153,7 +145,6 @@ main(int argc, char *argv[])
 		err(1, "stdout");
 	(void)fclose(fp);
 
-#ifdef LOOKUP
 	/* init lookup table */
 	for (i = 0; i < UCHAR_MAX + 1; i++)
 	    	for (j = 0; j < UCHAR_MAX + 1; j++) 
@@ -162,8 +153,6 @@ main(int argc, char *argv[])
 	for (cp = bigrams, i = 0; *cp != '\0'; i += 2, cp += 2)
 	        big[(u_char)*cp][(u_char)*(cp + 1)] = (bg_t)i;
 
-#endif /* LOOKUP */
-
 	oldpath = buf1;
 	path = buf2;
 	oldcount = 0;
@@ -176,13 +165,6 @@ main(int argc, char *argv[])
 
 		/* remove newline */
 		for (cp = path; *cp != '\0'; cp++) {
-#ifndef LOCATE_CHAR30
-			/* old locate implementations core'd for char 30 */
-			if (*cp == SWITCH)
-				*cp = '?';
-			else
-#endif /* !LOCATE_CHAR30 */
-
 			/* chop newline */
 			if (*cp == '\n')
 				*cp = '\0';
@@ -257,21 +239,6 @@ main(int argc, char *argv[])
 	exit(0);
 }
 
-#ifndef LOOKUP
-int
-bgindex(char *bg)		/* Return location of bg in bigrams or -1. */
-{
-	char bg0, bg1, *p;
-
-	bg0 = bg[0];
-	bg1 = bg[1];
-	for (p = bigrams; *p != NULL; p++)
-		if (*p++ == bg0 && *p == bg1)
-			break;
-	return (*p == NULL ? -1 : (--p - bigrams));
-}
-#endif /* !LOOKUP */
-
 void
 usage(void)
 {