diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2022-04-08 12:12:53 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2022-04-08 12:12:53 +0200 |
commit | 86a570c792e692d711dc4dc8530ff54b9980c0a4 (patch) | |
tree | c07e64d417872c29bebc31037b780558be06d5ff /libbuild2 | |
parent | 230e7cb0bab4582132de2bc411e355eacbacff4a (diff) |
Optimize update_during_match()
Diffstat (limited to 'libbuild2')
-rw-r--r-- | libbuild2/algorithm.cxx | 21 | ||||
-rw-r--r-- | libbuild2/target.ixx | 4 |
2 files changed, 17 insertions, 8 deletions
diff --git a/libbuild2/algorithm.cxx b/libbuild2/algorithm.cxx index 8b1d2fc..5011b26 100644 --- a/libbuild2/algorithm.cxx +++ b/libbuild2/algorithm.cxx @@ -2113,6 +2113,10 @@ namespace build2 // causes the target state to be automatically set to unchanged) if the // file is known to be up to date. So we do the update "smartly". // + // Also, now that we do header pre-generation by default, there is a good + // chance the header has already been updated. So we also detect that and + // avoid switching the phase. + // const path_target* pt (t.is_a<path_target> ()); if (pt == nullptr) @@ -2140,11 +2144,14 @@ namespace build2 // target_state::changed because of the dynamic dependency extraction // run for some other target. // - // @@ MT perf: so we are going to switch the phase and execute for - // any generated header. - // - phase_switch ps (t.ctx, run_phase::execute); - target_state ns (execute_direct_sync (a, t)); + target_state ns; + if (os != target_state::changed) + { + phase_switch ps (t.ctx, run_phase::execute); + ns = execute_direct_sync (a, t); + } + else + ns = os; if (ns != os && ns != target_state::unchanged) { @@ -2204,9 +2211,9 @@ namespace build2 bool r (false); - // @@ Maybe we should optimize for n == 1? + // @@ Maybe we should optimize for n == 1? Maybe we should just call + // smarter update_during_match() in this case? // - #if 0 for (prerequisite_target& p: pts) { diff --git a/libbuild2/target.ixx b/libbuild2/target.ixx index af75cd1..ecc16c4 100644 --- a/libbuild2/target.ixx +++ b/libbuild2/target.ixx @@ -302,7 +302,9 @@ namespace build2 return make_pair (false, target_state::unknown); else { - // Normally applied but can also be already executed. + // Normally applied but can also be already executed. Note that in the + // latter case we are guaranteed to be synchronized since we are in the + // match phase. // assert (o == offset_applied || o == offset_executed); return make_pair (true, (group_state (a) ? group->state[a] : s).state); |