]> git.tdb.fi Git - builder.git/commitdiff
Avoid observing the same header twice in ObjectFile
authorMikko Rasa <tdb@tdb.fi>
Fri, 30 Dec 2022 22:34:41 +0000 (00:34 +0200)
committerMikko Rasa <tdb@tdb.fi>
Fri, 30 Dec 2022 22:34:41 +0000 (00:34 +0200)
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

index 00fa6792859962e9a1a0b984bdde70b8c86bf3e4..65ad4330cb740b6ecc57e7f9fd4f8b3783e93399 100644 (file)
@@ -54,11 +54,12 @@ void ObjectFile::find_dependencies()
        vector<FileTarget *> 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<void (ObjectFile::*)()>(&ObjectFile::find_dependencies)));
-       }
+               if(!any_equals(depends, static_cast<Target *>(h)))
+               {
+                       add_dependency(*h);
+                       if(h->get_real_target()->is_buildable())
+                               h->signal_modified.connect(sigc::mem_fun(this, static_cast<void (ObjectFile::*)()>(&ObjectFile::find_dependencies)));
+               }
 }
 
 void ObjectFile::find_dependencies(FileTarget &tgt, vector<FileTarget *> &headers)