From f5e2fc474db076f35e8badb239661cbf283d5003 Mon Sep 17 00:00:00 2001 From: Benjamin Kramer Date: Fri, 29 May 2015 19:43:39 +0000 Subject: Replace push_back(Constructor(foo)) with emplace_back(foo) for non-trivial types If the type isn't trivially moveable emplace can skip a potentially expensive move. It also saves a couple of characters. Call sites were found with the ASTMatcher + some semi-automated cleanup. memberCallExpr( argumentCountIs(1), callee(methodDecl(hasName("push_back"))), on(hasType(recordDecl(has(namedDecl(hasName("emplace_back")))))), hasArgument(0, bindTemporaryExpr( hasType(recordDecl(hasNonTrivialDestructor())), has(constructExpr()))), unless(isInTemplateInstantiation())) No functional change intended. llvm-svn: 238602 --- llvm/lib/ExecutionEngine/ExecutionEngineBindings.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'llvm/lib/ExecutionEngine/ExecutionEngineBindings.cpp') diff --git a/llvm/lib/ExecutionEngine/ExecutionEngineBindings.cpp b/llvm/lib/ExecutionEngine/ExecutionEngineBindings.cpp index ce1ab594dfa..97d7b97fdfe 100644 --- a/llvm/lib/ExecutionEngine/ExecutionEngineBindings.cpp +++ b/llvm/lib/ExecutionEngine/ExecutionEngineBindings.cpp @@ -254,11 +254,8 @@ int LLVMRunFunctionAsMain(LLVMExecutionEngineRef EE, LLVMValueRef F, unsigned ArgC, const char * const *ArgV, const char * const *EnvP) { unwrap(EE)->finalizeObject(); - - std::vector ArgVec; - for (unsigned I = 0; I != ArgC; ++I) - ArgVec.push_back(ArgV[I]); - + + std::vector ArgVec(ArgV, ArgV + ArgC); return unwrap(EE)->runFunctionAsMain(unwrap(F), ArgVec, EnvP); } -- cgit v1.2.3