[ExpressionParser] Reserve size before copying over args
authorJonas Devlieghere <jonas@devlieghere.com>
Fri, 21 Dec 2018 22:16:10 +0000 (22:16 +0000)
committerJonas Devlieghere <jonas@devlieghere.com>
Fri, 21 Dec 2018 22:16:10 +0000 (22:16 +0000)
We already know the final size here so we might as well reserve it so we
don't have to re-allocate during the loop.

llvm-svn: 349967

lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp

index 049f5b0..ced21df 100644 (file)
@@ -608,7 +608,8 @@ ClangModulesDeclVendor::Create(Target &target) {
                                                  new StoringDiagnosticConsumer);
 
   std::vector<const char *> compiler_invocation_argument_cstrs;
-
+  compiler_invocation_argument_cstrs.reserve(
+      compiler_invocation_arguments.size());
   for (const std::string &arg : compiler_invocation_arguments) {
     compiler_invocation_argument_cstrs.push_back(arg.c_str());
   }