diff options
author | Benjamin Kramer <benny.kra@googlemail.com> | 2012-02-14 12:06:21 +0000 |
---|---|---|
committer | Benjamin Kramer <benny.kra@googlemail.com> | 2012-02-14 12:06:21 +0000 |
commit | 14c598268ff7534d3753ae84eba9b8a81bf0bf8f (patch) | |
tree | 9738b30d50ace204cca6c36e30fcbb87f282ca7f /lib/CodeGen/CGExprConstant.cpp | |
parent | 3164c14cadbb09a05ba811602221e9156077cf44 (diff) |
Use a simpler (and more efficient) pattern to pad vectors.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150475 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGExprConstant.cpp')
-rw-r--r-- | lib/CodeGen/CGExprConstant.cpp | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/lib/CodeGen/CGExprConstant.cpp b/lib/CodeGen/CGExprConstant.cpp index 0b3ac9cbe5..44531c0992 100644 --- a/lib/CodeGen/CGExprConstant.cpp +++ b/lib/CodeGen/CGExprConstant.cpp @@ -701,9 +701,9 @@ public: // Copy initializer elements. std::vector<llvm::Constant*> Elts; Elts.reserve(NumInitableElts + NumElements); - unsigned i = 0; + bool RewriteType = false; - for (; i < NumInitableElts; ++i) { + for (unsigned i = 0; i < NumInitableElts; ++i) { Expr *Init = ILE->getInit(i); llvm::Constant *C = CGM.EmitConstantExpr(Init, Init->getType(), CGF); if (!C) @@ -722,8 +722,7 @@ public: if (!fillC) return 0; RewriteType |= (fillC->getType() != ElemTy); - for (; i < NumElements; ++i) - Elts.push_back(fillC); + Elts.resize(NumElements, fillC); if (RewriteType) { // FIXME: Try to avoid packing the array |