summaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authorPaul Smith <psmith@gnu.org>2005-04-13 03:16:33 +0000
committerPaul Smith <psmith@gnu.org>2005-04-13 03:16:33 +0000
commit49ee105c685cb84bc3057e8b7666fc0cc7090047 (patch)
tree178eec81c5e39f56db9ca4b513376b3e1c5d35bf /main.c
parent3daf8df6ee835b9edcc068af33ae97910bb8d934 (diff)
downloadgunmake-49ee105c685cb84bc3057e8b7666fc0cc7090047.tar.gz
Fix performance degradation introduced by the second expansion feature.
I did this by adding intelligence into the algorithm such that the second expansion was only actually performed when the prerequisite list contained at least one "$", so we knew it is actually needed. Without this we were using up a LOT more memory, since every single target (even ones never used by make) had their file variables initialized. This also used a lot more CPU, since we needed to create and populate a new variable hash table for every target. There is one issue remaining with this feature: it leaks memory. In pattern_search() we now initialize the file variables for every pattern target, which allocates a hash table, etc. However, sometimes we recursively invoke pattern_search() (for intermediate files) with an automatic variable (alloca() I believe) as the file. When that function returns, obviously, the file variable hash memory is lost.
Diffstat (limited to 'main.c')
-rw-r--r--main.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/main.c b/main.c
index 014c41f..b99bf27 100644
--- a/main.c
+++ b/main.c
@@ -2125,6 +2125,7 @@ main (int argc, char **argv, char **envp)
goals->next = 0;
goals->name = 0;
goals->ignore_mtime = 0;
+ goals->need_2nd_expansion = 0;
goals->file = default_goal_file;
}
}
@@ -2290,6 +2291,7 @@ handle_non_switch_argument (char *arg, int env)
lastgoal->name = 0;
lastgoal->file = f;
lastgoal->ignore_mtime = 0;
+ lastgoal->need_2nd_expansion = 0;
{
/* Add this target name to the MAKECMDGOALS variable. */