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 --- libbuild2/variable.hxx | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'libbuild2/variable.hxx') diff --git a/libbuild2/variable.hxx b/libbuild2/variable.hxx index 3b444e6..400aaf1 100644 --- a/libbuild2/variable.hxx +++ b/libbuild2/variable.hxx @@ -16,6 +16,7 @@ #include #include +#include #include @@ -1470,7 +1471,21 @@ namespace build2 auto r (map_.insert (map::value_type (&n, move (var)))); if (r.second) + { +#if 0 + if (shared_ && outer_ == nullptr) // Global pool in context. + { + size_t n (map_.bucket_count ()); + if (n > buckets_) + { + text << "variable_pool buckets: " << buckets_ << " -> " << n + << " (" << map_.size () << ")"; + buckets_ = n; + } + } +#endif r.first->first.p = &r.first->second.name; + } return r; } @@ -1482,6 +1497,10 @@ namespace build2 variable_pool* outer_; const variable_patterns* patterns_; map map_; + +#if 0 + size_t buckets_ = 0; +#endif }; // Variable patterns. -- cgit v1.1