From 6fcd905aacf302540bbc3e84671dba9222e2d06b Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Sat, 31 Dec 2022 00:34:41 +0200 Subject: [PATCH] Avoid observing the same header twice in ObjectFile This is a bit crude since the dependencies are not sorted, but still avoids a massive slowdown from updating dependencies many times when a header is generated. --- source/lib/objectfile.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/source/lib/objectfile.cpp b/source/lib/objectfile.cpp index 00fa679..65ad433 100644 --- a/source/lib/objectfile.cpp +++ b/source/lib/objectfile.cpp @@ -54,11 +54,12 @@ void ObjectFile::find_dependencies() vector headers; find_dependencies(source, headers); for(FileTarget *h: headers) - { - add_dependency(*h); - if(h->get_real_target()->is_buildable()) - h->signal_modified.connect(sigc::mem_fun(this, static_cast(&ObjectFile::find_dependencies))); - } + if(!any_equals(depends, static_cast(h))) + { + add_dependency(*h); + if(h->get_real_target()->is_buildable()) + h->signal_modified.connect(sigc::mem_fun(this, static_cast(&ObjectFile::find_dependencies))); + } } void ObjectFile::find_dependencies(FileTarget &tgt, vector &headers) -- 2.43.0