Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/make Reuse the Hash_Entry `name' field to store the ...
details: https://anonhg.NetBSD.org/src/rev/f28c06b0f4f9
branches: trunk
changeset: 476406:f28c06b0f4f9
user: sommerfeld <sommerfeld%NetBSD.org@localhost>
date: Wed Sep 15 22:51:05 1999 +0000
description:
Reuse the Hash_Entry `name' field to store the variable name when we
can (i.e., everything except environment variables, which aren't
stored in hash tables).
While we're here, inline the body of VarDelete into Var_Delete since
it's the only caller and it's just simpler that way when v->name can
share storage with the hash entry and may not need to be freed
separately.
Speeds up the infamous libc build benchhmark maybe 1% on PIII, 4% on
alpha pc164
Suggested by Perry Metzger.
diffstat:
usr.bin/make/var.c | 40 ++++++++--------------------------------
1 files changed, 8 insertions(+), 32 deletions(-)
diffs (94 lines):
diff -r db9eaccca363 -r f28c06b0f4f9 usr.bin/make/var.c
--- a/usr.bin/make/var.c Wed Sep 15 21:54:57 1999 +0000
+++ b/usr.bin/make/var.c Wed Sep 15 22:51:05 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: var.c,v 1.36 1999/09/15 02:56:35 mycroft Exp $ */
+/* $NetBSD: var.c,v 1.37 1999/09/15 22:51:05 sommerfeld Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -39,14 +39,14 @@
*/
#ifdef MAKE_BOOTSTRAP
-static char rcsid[] = "$NetBSD: var.c,v 1.36 1999/09/15 02:56:35 mycroft Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.37 1999/09/15 22:51:05 sommerfeld Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)var.c 8.3 (Berkeley) 3/19/94";
#else
-__RCSID("$NetBSD: var.c,v 1.36 1999/09/15 02:56:35 mycroft Exp $");
+__RCSID("$NetBSD: var.c,v 1.37 1999/09/15 22:51:05 sommerfeld Exp $");
#endif
#endif /* not lint */
#endif
@@ -180,7 +180,6 @@
static Var *VarFind __P((char *, GNode *, int));
static void VarAdd __P((char *, char *, GNode *));
-static void VarDelete __P((ClientData));
static Boolean VarHead __P((char *, Boolean, Buffer, ClientData));
static Boolean VarTail __P((char *, Boolean, Buffer, ClientData));
static Boolean VarSuffix __P((char *, Boolean, Buffer, ClientData));
@@ -344,8 +343,6 @@
v = (Var *) emalloc (sizeof (Var));
- v->name = estrdup (name);
-
len = val ? strlen(val) : 0;
v->val = Buf_Init(len+1);
Buf_AddBytes(v->val, len, (Byte *)val);
@@ -354,36 +351,12 @@
h = Hash_CreateEntry (&ctxt->context, name, NULL);
Hash_SetValue(h, v);
+ v->name = h->name;
if (DEBUG(VAR)) {
printf("%s:%s = %s\n", ctxt->name, name, val);
}
}
-
-/*-
- *-----------------------------------------------------------------------
- * VarDelete --
- * Delete a variable and all the space associated with it.
- *
- * Results:
- * None
- *
- * Side Effects:
- * None
- *-----------------------------------------------------------------------
- */
-static void
-VarDelete(vp)
- ClientData vp;
-{
- Var *v = (Var *) vp;
- free(v->name);
- Buf_Destroy(v->val, TRUE);
- free((Address) v);
-}
-
-
-
/*-
*-----------------------------------------------------------------------
* Var_Delete --
@@ -412,8 +385,11 @@
register Var *v;
v = (Var *)Hash_GetValue(ln);
+ if (v->name != ln->name)
+ free(v->name);
Hash_DeleteEntry(&ctxt->context, ln);
- VarDelete((ClientData) v);
+ Buf_Destroy(v->val, TRUE);
+ free((Address) v);
}
}
Home |
Main Index |
Thread Index |
Old Index