aboutsummaryrefslogtreecommitdiff
path: root/build2
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2022-11-30 11:49:56 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2022-11-30 11:49:56 +0200
commit59f70280dee90957a672810a3845af2dec8552e8 (patch)
tree609b729c394b44a38418a6f19d03893dbfbd0e9f /build2
parent3bbbe09e8629ab5311a1bcbb9f56aa6a33e36f55 (diff)
Reserve targets, variables to avoid rehashing
Diffstat (limited to 'build2')
-rw-r--r--build2/b.cxx18
1 files changed, 18 insertions, 0 deletions
diff --git a/build2/b.cxx b/build2/b.cxx
index f91eff5..68c77c8 100644
--- a/build2/b.cxx
+++ b/build2/b.cxx
@@ -468,6 +468,24 @@ main (int argc, char* argv[])
if (bspec.empty ())
bspec.push_back (metaopspec ()); // Default meta-operation.
+ // The reserve values were picked experimentally. They allow building a
+ // sample application that depends on Qt and Boost without causing a
+ // rehash.
+ //
+ // Note: omit reserving anything for the info meta-operation since it
+ // won't be loading the buildfiles and needs to be as fast as possible.
+ //
+ if (bspec.size () == 1 &&
+ bspec.front ().size () == 1 &&
+ (bspec.front ().name == "info" ||
+ (bspec.front ().name.empty () &&
+ bspec.front ().front ().name == "info")))
+ ;
+ else
+ pctx->reserve (context::reserves {
+ 30000 /* targets */,
+ 1100 /* variables */});
+
const path& buildfile (ops.buildfile_specified ()
? ops.buildfile ()
: empty_path);