From c75489e7c2a5a0558f8579581d1e1186b6bd89ce Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 17 Jun 2015 11:12:59 +0200 Subject: Reserve enough space in "storage" vector to ensure no reallocations --- build/cxx/rule.cxx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'build/cxx') 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 relo; scope& rs (*t.root_scope ()); // Shouldn't have matched if nullptr. vector 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 relo; + relo.reserve (t.prerequisite_targets.size ()); + for (target* pt: t.prerequisite_targets) { path_target* ppt; -- cgit v1.1