diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2022-11-30 11:49:56 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2022-11-30 11:49:56 +0200 |
commit | 59f70280dee90957a672810a3845af2dec8552e8 (patch) | |
tree | 609b729c394b44a38418a6f19d03893dbfbd0e9f /libbuild2/context.hxx | |
parent | 3bbbe09e8629ab5311a1bcbb9f56aa6a33e36f55 (diff) |
Reserve targets, variables to avoid rehashing
Diffstat (limited to 'libbuild2/context.hxx')
-rw-r--r-- | libbuild2/context.hxx | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/libbuild2/context.hxx b/libbuild2/context.hxx index b71a068..27c3cc0 100644 --- a/libbuild2/context.hxx +++ b/libbuild2/context.hxx @@ -652,6 +652,15 @@ namespace build2 // Note: see also the trace_* data members that, if needed, must be set // separately, after construction. // + struct reserves + { + size_t targets; + size_t variables; + + reserves (): targets (0), variables (0) {} + reserves (size_t t, size_t v): targets (t), variables (v) {} + }; + explicit context (scheduler&, global_mutexes&, @@ -662,9 +671,17 @@ namespace build2 bool no_diag_buffer = false, bool keep_going = true, const strings& cmd_vars = {}, + reserves = {0, 160}, optional<context*> module_context = nullptr, const loaded_modules_lock* inherited_mudules_lock = nullptr); + // Reserve elements in containers to avoid re-allocation/re-hashing. Zero + // values are ignored (that is, the corresponding container reserve() + // function is not called). Can only be called in the load phase. + // + void + reserve (reserves); + // Enter project-wide (as opposed to global) variable overrides. // void |