[LLVMbugs] [Bug 12999] New: unordered_set::insert calls operator new when no insert occurs

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu May 31 13:31:11 PDT 2012


http://llvm.org/bugs/show_bug.cgi?id=12999

             Bug #: 12999
           Summary: unordered_set::insert calls operator new when no
                    insert occurs
           Product: libc++
           Version: unspecified
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: All Bugs
        AssignedTo: hhinnant at apple.com
        ReportedBy: gratal at gmail.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified


When calling insert on an unordered_set with an element that is already in the
list, operator new gets called. This can lead to horrible performance when
multiple repeated elements are inserted into a set. This doesn't happen in
libstdc++.

Example code:


#include <unordered_set>

int main()
{
    std::unordered_set<int> s;

    for(int i=0;i<100000;i++)  
        s.insert(3);
}


This will call operator new 100000 times, compared to just 1 in libstdc++.

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list