Module Name: src Committed By: rillig Date: Sun Aug 23 06:54:01 UTC 2020
Modified Files: src/usr.bin/make: suff.c Log Message: make(1): unroll loop in SuffFindArchiveDeps The compiler had unrolled this loop anyway, and for humans it is more readable as well. The comments "must be first" and "must be second" came from a time when the variables were stored in a linked list instead of a hash table. Maybe this "must" was about performance back then. Anyway, the tests run fine with either order, and there is absolutely no evidence that the order of these variables could have any effect. To generate a diff of this commit: cvs rdiff -u -r1.112 -r1.113 src/usr.bin/make/suff.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/usr.bin/make/suff.c diff -u src/usr.bin/make/suff.c:1.112 src/usr.bin/make/suff.c:1.113 --- src/usr.bin/make/suff.c:1.112 Sat Aug 22 22:57:53 2020 +++ src/usr.bin/make/suff.c Sun Aug 23 06:54:01 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: suff.c,v 1.112 2020/08/22 22:57:53 rillig Exp $ */ +/* $NetBSD: suff.c,v 1.113 2020/08/23 06:54:01 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -69,14 +69,14 @@ */ #ifndef MAKE_NATIVE -static char rcsid[] = "$NetBSD: suff.c,v 1.112 2020/08/22 22:57:53 rillig Exp $"; +static char rcsid[] = "$NetBSD: suff.c,v 1.113 2020/08/23 06:54:01 rillig Exp $"; #else #include <sys/cdefs.h> #ifndef lint #if 0 static char sccsid[] = "@(#)suff.c 8.4 (Berkeley) 3/21/94"; #else -__RCSID("$NetBSD: suff.c,v 1.112 2020/08/22 22:57:53 rillig Exp $"); +__RCSID("$NetBSD: suff.c,v 1.113 2020/08/23 06:54:01 rillig Exp $"); #endif #endif /* not lint */ #endif @@ -1886,13 +1886,7 @@ SuffFindArchiveDeps(GNode *gn, Lst slst) char *eoarch; /* End of archive portion */ char *eoname; /* End of member portion */ GNode *mem; /* Node for member */ - static const char *copy[] = { - /* Variables to be copied from the member node */ - TARGET, /* Must be first */ - PREFIX, /* Must be second */ - }; LstNode ln, nln; /* Next suffix node to check */ - int i; /* Index into copy and vals */ Suff *ms; /* Suffix descriptor for member */ char *name; /* Start of member's name */ @@ -1935,11 +1929,12 @@ SuffFindArchiveDeps(GNode *gn, Lst slst) /* * Copy in the variables from the member node to this one. */ - for (i = (sizeof(copy)/sizeof(copy[0]))-1; i >= 0; i--) { - char *p1; - Var_Set(copy[i], Var_Value(copy[i], mem, &p1), gn); - bmake_free(p1); - + { + char *freeIt; + Var_Set(PREFIX, Var_Value(PREFIX, mem, &freeIt), gn); + bmake_free(freeIt); + Var_Set(TARGET, Var_Value(TARGET, mem, &freeIt), gn); + bmake_free(freeIt); } ms = mem->suffix;