diff options
author | Benjamin Kramer <benny.kra@googlemail.com> | 2015-02-17 15:29:18 +0000 |
---|---|---|
committer | Benjamin Kramer <benny.kra@googlemail.com> | 2015-02-17 15:29:18 +0000 |
commit | 6cd780ff2143656df213359b7a6df9a5a9237e17 (patch) | |
tree | b3689d2b8496e1cc569d85b5c59b0ac1d68beace /llvm/lib/IR/DebugInfo.cpp | |
parent | 2ba8778157390981ba1e4a3b683aee09aa9f009f (diff) | |
download | bcm5719-llvm-6cd780ff2143656df213359b7a6df9a5a9237e17.tar.gz bcm5719-llvm-6cd780ff2143656df213359b7a6df9a5a9237e17.zip |
Prefer SmallVector::append/insert over push_back loops.
Same functionality, but hoists the vector growth out of the loop.
llvm-svn: 229500
Diffstat (limited to 'llvm/lib/IR/DebugInfo.cpp')
-rw-r--r-- | llvm/lib/IR/DebugInfo.cpp | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/llvm/lib/IR/DebugInfo.cpp b/llvm/lib/IR/DebugInfo.cpp index deeaae7d5de..76b21d8d09d 100644 --- a/llvm/lib/IR/DebugInfo.cpp +++ b/llvm/lib/IR/DebugInfo.cpp @@ -344,9 +344,7 @@ void DIDescriptor::replaceAllUsesWith(LLVMContext &VMContext, DIDescriptor D) { // itself. const MDNode *DN = D; if (DbgNode == DN) { - SmallVector<Metadata *, 10> Ops(DbgNode->getNumOperands()); - for (size_t i = 0; i != Ops.size(); ++i) - Ops[i] = DbgNode->getOperand(i); + SmallVector<Metadata *, 10> Ops(DbgNode->op_begin(), DbgNode->op_end()); DN = MDNode::get(VMContext, Ops); } @@ -884,9 +882,8 @@ DIVariable llvm::createInlinedVariable(MDNode *DV, MDNode *InlinedScope, return cleanseInlinedVariable(DV, VMContext); // Insert inlined scope. - SmallVector<Metadata *, 8> Elts; - for (unsigned I = 0, E = DIVariableInlinedAtIndex; I != E; ++I) - Elts.push_back(DV->getOperand(I)); + SmallVector<Metadata *, 8> Elts(DV->op_begin(), + DV->op_begin() + DIVariableInlinedAtIndex); Elts.push_back(InlinedScope); DIVariable Inlined(MDNode::get(VMContext, Elts)); @@ -900,9 +897,8 @@ DIVariable llvm::cleanseInlinedVariable(MDNode *DV, LLVMContext &VMContext) { return DIVariable(DV); // Remove inlined scope. - SmallVector<Metadata *, 8> Elts; - for (unsigned I = 0, E = DIVariableInlinedAtIndex; I != E; ++I) - Elts.push_back(DV->getOperand(I)); + SmallVector<Metadata *, 8> Elts(DV->op_begin(), + DV->op_begin() + DIVariableInlinedAtIndex); DIVariable Cleansed(MDNode::get(VMContext, Elts)); assert(Cleansed.Verify() && "Expected to create a DIVariable"); |