Merge "Add usesninjalogasweightlist option"
diff --git a/src/build.cc b/src/build.cc
index d21115d..4ccfaf3 100644
--- a/src/build.cc
+++ b/src/build.cc
@@ -687,7 +687,8 @@
 
       std::set<Edge*, EdgeCmp> next_edges;
       for (auto* next_node : e->inputs_) {
-        if (!next_node) {
+        // Skip if the next node isn't dirty because actual build also skips the node.
+        if (!next_node || !next_node->dirty()) {
           continue;
         }
         auto* next_e = next_node->in_edge();