From 59f70280dee90957a672810a3845af2dec8552e8 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 30 Nov 2022 11:49:56 +0200 Subject: Reserve targets, variables to avoid rehashing --- build2/b.cxx | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'build2') 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); -- cgit v1.1