Closed
Bug 580633
Opened 13 years ago
Closed 13 years ago
Do less copying when adding elements to HashMap
Categories
(Core :: JavaScript Engine, defect)
Core
JavaScript Engine
Tracking
()
RESOLVED
FIXED
People
(Reporter: luke, Assigned: luke)
Details
(Whiteboard: fixed-in-tracemonkey)
Attachments
(1 file)
3.31 KB,
patch
|
bzbarsky
:
review+
|
Details | Diff | Splinter Review |
Although it boils away for builtin types, if you are storing a key or value with a non-trivial operator=/copy-constructor, HashMap will copy more than it needs to when inserting elements. The solution is to make HashTable's interface a bit more fragile, which is fine since its an implementation detail of HashMap/HashSet, and let the caller do the assignment directly.
Attachment #459012 -
Flags: review?(bzbarsky)
![]() |
||
Comment 1•13 years ago
|
||
Comment on attachment 459012 [details] [diff] [review] fix Looks fine, but for HashMap (not HashSet, where the operation makes no sense), would it make sense to also add this function: bool add(AddPtr &p, const Key &k) { Entry *pentry; if (!impl.add(p, &pentry)) return false; const_cast<Key &>(pentry->key) = k; return true; } (relying on pentry->value being default-constructed already)? Or would that not work for some reason?
Attachment #459012 -
Flags: review?(bzbarsky) → review+
![]() |
Assignee | |
Comment 2•13 years ago
|
||
That would totally work
![]() |
||
Comment 3•13 years ago
|
||
Let's do that, then. Then we get no-copy inserts as needed!
![]() |
Assignee | |
Comment 4•13 years ago
|
||
http://hg.mozilla.org/tracemonkey/rev/116265442418 and with less fire http://hg.mozilla.org/tracemonkey/rev/0b8353af4300
![]() |
Assignee | |
Updated•13 years ago
|
Whiteboard: fixed-in-tracemonkey
Comment 5•13 years ago
|
||
http://hg.mozilla.org/mozilla-central/rev/116265442418
Status: ASSIGNED → RESOLVED
Closed: 13 years ago
Resolution: --- → FIXED
You need to log in
before you can comment on or make changes to this bug.
Description
•