aboutsummaryrefslogtreecommitdiff
path: root/build/cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2015-06-17 11:12:59 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2015-06-17 11:12:59 +0200
commitc75489e7c2a5a0558f8579581d1e1186b6bd89ce (patch)
tree2b01173860d93a9cdf1acb02580269f456fb152a /build/cxx
parent17850b7e936d9a8c38800360ab932367b8774813 (diff)
Reserve enough space in "storage" vector to ensure no reallocations
Diffstat (limited to 'build/cxx')
-rw-r--r--build/cxx/rule.cxx7
1 files changed, 6 insertions, 1 deletions
diff --git a/build/cxx/rule.cxx b/build/cxx/rule.cxx
index c9d451d..ebb95b9 100644
--- a/build/cxx/rule.cxx
+++ b/build/cxx/rule.cxx
@@ -888,7 +888,6 @@ namespace build
// results in easier to read diagnostics.
//
path relt (relative (t.path ()));
- vector<path> relo;
scope& rs (*t.root_scope ()); // Shouldn't have matched if nullptr.
vector<const char*> args;
@@ -919,6 +918,12 @@ namespace build
append_options (args, t, "cxx.loptions");
}
+ // Reserve enough space so that we don't reallocate. Reallocating
+ // means pointers to elements may no longer be valid.
+ //
+ vector<path> relo;
+ relo.reserve (t.prerequisite_targets.size ());
+
for (target* pt: t.prerequisite_targets)
{
path_target* ppt;