This is an archive of the discontinued LLVM Phabricator instance.

Fix PR12999 - unordered_set::insert calls operator new when no insert occurs
ClosedPublic

Authored by EricWF on Feb 11 2015, 3:19 PM.

Details

Summary

when unordered_set::insert(value_type&&) was called it would be treated like unordered_set::emplace(Args&&) and it would allocate and construct a node before trying to insert it.
This caused unnecessary allocations when the value was already in the set. This patch adds an overload to __hash_table::__insert_unique that specifically handles value_type&& more link value_type const &.

This patch also adds a single unified insert function for values into __hash_table called __insert_unique_value that handles the cases for __insert_unique(value_type&&) and __insert_unique(value_type const &).

This patch fixes PR12999: http://llvm.org/bugs/show_bug.cgi?id=12999.

Diff Detail

Event Timeline

EricWF updated this revision to Diff 19786.Feb 11 2015, 3:19 PM
EricWF retitled this revision from to Fix PR12999 - unordered_set::insert calls operator new when no insert occurs.
EricWF updated this object.
EricWF edited the test plan for this revision. (Show Details)
EricWF added reviewers: mclow.lists, danalbert.
EricWF added a subscriber: Unknown Object (MLST).

Adding Titus as a reviewer.

danalbert accepted this revision.Mar 31 2015, 10:20 AM
danalbert edited edge metadata.

LGTM.

This revision is now accepted and ready to land.Mar 31 2015, 10:20 AM

I can't find regarding @mclow.lists concerns about complexity requirements. This patch shouldn't change the complexity.

EricWF closed this revision.Jun 13 2015, 12:22 AM