[llvm-commits] [llvm] r147090 - /llvm/trunk/lib/CodeGen/MachineBlockPlacement.cpp

Chandler Carruth chandlerc at google.com
Wed Dec 21 14:11:16 PST 2011


On Wed, Dec 21, 2011 at 2:00 PM, Jakub Staszak <kubastaszak at gmail.com>wrote:

> operator[] inserts an object for key if it doesn't exist.
>
> // X is empty
> if (X[0] == a) { }
> if (X[1] == b) { }
> if (X[2] == c) { }
> // X.size() = 3
>
> This is the way that std::map works. I believe we want to be quite
> compatible here.


Certainly, but is it actually cheaper if you know ahead of time that no
such insertion will occur? I would expect the lookup path to a hot path
through the [] operators.

To be honest, I'm beginning to question the entire patch. No insertion ever
happens with these [] uses, and they seem more readable to me than
lookup... I don't feel strongly about the lookup, but I do feel strongly
about the const thing. I'd really rather you strip back out all the const
here.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20111221/38759749/attachment.html>


More information about the llvm-commits mailing list