[llvm-commits] [llvm] r52690 - /llvm/trunk/lib/VMCore/Constants.cpp
Dan Gohman
gohman at apple.com
Tue Jun 24 15:40:51 PDT 2008
On Jun 24, 2008, at 2:58 PM, Owen Anderson wrote:
> Author: resistor
> Date: Tue Jun 24 16:58:29 2008
> New Revision: 52690
>
> URL: http://llvm.org/viewvc/llvm-project?rev=52690&view=rev
> Log:
> In ConstantArray::getAsString(), we know the size of the resultant
> string in advance so we can pre-allocate it and just fill in
> the entries. This improves the time for the AsmPrinter on
> InstructionCombining.cpp from 0.4248s to 0.3370s.
>
> Modified:
> llvm/trunk/lib/VMCore/Constants.cpp
>
> Modified: llvm/trunk/lib/VMCore/Constants.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Constants.cpp?rev=52690&r1=52689&r2=52690&view=diff
>
> =
> =
> =
> =
> =
> =
> =
> =
> ======================================================================
> --- llvm/trunk/lib/VMCore/Constants.cpp (original)
> +++ llvm/trunk/lib/VMCore/Constants.cpp Tue Jun 24 16:58:29 2008
> @@ -1378,8 +1378,9 @@
> std::string ConstantArray::getAsString() const {
> assert(isString() && "Not a string!");
> std::string Result;
> + Result.reserve(getNumOperands());
This should be resize, not reserve.
>
> for (unsigned i = 0, e = getNumOperands(); i != e; ++i)
> - Result += (char)cast<ConstantInt>(getOperand(i))->getZExtValue();
> + Result[i] = (char)cast<ConstantInt>(getOperand(i))-
> >getZExtValue();
> return Result;
> }
Dan
More information about the llvm-commits
mailing list