[PATCH] Make StringMap aware of POD types
Michael Ilseman
milseman at apple.com
Mon Mar 17 14:25:46 PDT 2014
++ is non-trivial on maps, because it skips non-empty or tombstone buckets. As far as the inlining, I would think they’re all getting inlined, as they are all inline methods in StringMap.h
On Mar 17, 2014, at 2:18 PM, Pete Cooper <peter_cooper at apple.com> wrote:
>
> On Mar 17, 2014, at 1:15 PM, Benjamin Kramer <benny.kra at gmail.com> wrote:
>
>>
>> On 17.03.2014, at 20:38, Chandler Carruth <chandlerc at google.com> wrote:
>>
>>>
>>> On Mon, Mar 17, 2014 at 12:32 PM, Pete Cooper <peter_cooper at apple.com> wrote:
>>> I was worried about duplication, but actually that might be cleaner. I’ll give that a try now.
>>>
>>> If the duplication is a problem, factor that into a private helper function used by both?
>>
>> It can be written in two lines, not worth its own function.
> Agreed.
>>
>> for (auto &Entry : this)
>> Entry.Destroy(Allocator);
> Thanks for this. Its a nice small snippet. I tweaked it to this:
>
> if (!empty()) {
> for (auto &Entry : *this)
> Entry.Destroy(Allocator);
>
> However, this is still about 10% faster
>
>
> if (!empty()) {
> for (unsigned I = 0, E = NumBuckets; I != E; ++I) {
> StringMapEntryBase *&Bucket = TheTable[I];
> if (Bucket && Bucket != getTombstoneVal()) {
> static_cast<MapEntryTy*>(Bucket)->Destroy(Allocator);
> }
> }
> }
>
> The problem is that iterator++ isn’t getting optimized out. Actually neither is the whole loop I gave, but somehow it runs a bit quicker. I think its failing to inline ++ as it shows up in the trace even on -O3.
>
> Pete
>>
>> - Ben
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140317/da2a5d3f/attachment.html>
More information about the llvm-commits
mailing list