From 6dfe1d848edc32e492f0334258d3b715ba0bdc51 Mon Sep 17 00:00:00 2001 From: Hartmut Brandt Date: Thu, 10 Mar 2005 14:54:47 +0000 Subject: [PATCH] Reorganize Suff_EndTransform to be called only for nodes for which it is needed (transforms). --- usr.bin/make/parse.c | 14 +++++---- usr.bin/make/suff.c | 70 ++++++++++++++++++++------------------------ usr.bin/make/suff.h | 2 +- 3 files changed, 41 insertions(+), 45 deletions(-) diff --git a/usr.bin/make/parse.c b/usr.bin/make/parse.c index 3e25a8e18c66..bb3653176521 100644 --- a/usr.bin/make/parse.c +++ b/usr.bin/make/parse.c @@ -2367,12 +2367,16 @@ ParseReadLine(void) static void ParseFinishLine(void) { + const LstNode *ln; - if (inLine) { - Lst_ForEach(&targets, Suff_EndTransform, NULL); - Lst_Destroy(&targets, ParseHasCommands); - inLine = FALSE; - } + if (inLine) { + LST_FOREACH(ln, &targets) { + if (((const GNode *)Lst_Datum(ln))->type & OP_TRANSFORM) + Suff_EndTransform(Lst_Datum(ln)); + } + Lst_Destroy(&targets, ParseHasCommands); + inLine = FALSE; + } } diff --git a/usr.bin/make/suff.c b/usr.bin/make/suff.c index 5a4e2ae421f4..cdccd6c15e10 100644 --- a/usr.bin/make/suff.c +++ b/usr.bin/make/suff.c @@ -653,11 +653,8 @@ Suff_AddTransform(char *line) * Suff_EndTransform -- * Handle the finish of a transformation definition, removing the * transformation from the graph if it has neither commands nor - * sources. This is a callback procedure for the Parse module via - * Lst_ForEach - * - * Results: - * === 0 + * sources. This is called from the Parse module at the end of + * a dependency block. * * Side Effects: * If the node has no commands or children, the children and parents @@ -665,45 +662,40 @@ Suff_AddTransform(char *line) * *----------------------------------------------------------------------- */ -int -Suff_EndTransform(void *gnp, void *dummy __unused) +void +Suff_EndTransform(const GNode *gn) { - GNode *gn = (GNode *)gnp; + Suff *s, *t; - if ((gn->type & OP_TRANSFORM) && Lst_IsEmpty(&gn->commands) && - Lst_IsEmpty(&gn->children)) { - Suff *s, *t; - - /* - * SuffParseTransform() may fail for special rules which are not - * actual transformation rules (e.g., .DEFAULT). - */ - if (!SuffParseTransform(gn->name, &s, &t)) - return (0); - - DEBUGF(SUFF, ("deleting transformation from `%s' to `%s'\n", - s->name, t->name)); - - /* - * Remove the source from the target's children list. We check - * for a NULL return to handle a beanhead saying something like - * .c.o .c.o: - * - * We'll be called twice when the next target is seen, but .c - * and .o are only linked once... - */ - SuffRemove(&t->children, s); - - /* - * Remove the target from the source's parents list - */ - SuffRemove(&s->parents, t); - - } else if (gn->type & OP_TRANSFORM) { + if (!Lst_IsEmpty(&gn->commands) || !Lst_IsEmpty(&gn->children)) { DEBUGF(SUFF, ("transformation %s complete\n", gn->name)); + return; } - return (0); + /* + * SuffParseTransform() may fail for special rules which are not + * actual transformation rules (e.g., .DEFAULT). + */ + if (!SuffParseTransform(gn->name, &s, &t)) + return; + + DEBUGF(SUFF, ("deleting transformation from `%s' to `%s'\n", + s->name, t->name)); + + /* + * Remove the source from the target's children list. We check + * for a NULL return to handle a beanhead saying something like + * .c.o .c.o: + * + * We'll be called twice when the next target is seen, but .c + * and .o are only linked once... + */ + SuffRemove(&t->children, s); + + /* + * Remove the target from the source's parents list + */ + SuffRemove(&s->parents, t); } /*- diff --git a/usr.bin/make/suff.h b/usr.bin/make/suff.h index 35887ca57f41..8e1b406a1de4 100644 --- a/usr.bin/make/suff.h +++ b/usr.bin/make/suff.h @@ -46,7 +46,7 @@ struct GNode; void Suff_ClearSuffixes(void); Boolean Suff_IsTransform(char *); struct GNode *Suff_AddTransform(char *); -int Suff_EndTransform(void *, void *); +void Suff_EndTransform(const struct GNode *); void Suff_AddSuffix(char *); Lst *Suff_GetPath(char *); void Suff_DoPaths(void);