Remove mozilla::Pair
Categories
(Core :: MFBT, defect)
Tracking
()
Tracking | Status | |
---|---|---|
firefox76 | --- | fixed |
People
(Reporter: ekr, Assigned: fronkc1)
References
Details
Attachments
(1 file, 1 obsolete file)
std::pair is used throughout the Firefox code base (https://dxr.mozilla.org/mozilla-central/search?q=std%3A%3Apair&redirect=true), including in lots libraries which we pull from upstream and aren't going to change. mozilla::pair is used almost nowhere (https://dxr.mozilla.org/mozilla-central/search?q=%2Btype-ref%3Amozilla%3A%3APair) I've heard claims that mozilla::pair exists to deal with implementation quality issues in std::pair (https://groups.google.com/forum/#!topic/mozilla.dev.platform/IQhGdhGxx2M) but as a practical matter, it seems clear that we've standardized on std::pair, so even if this is true, it's largely too late. I propose that we recognize the facts on the ground, remove mozilla::Pair, and recommend that people use the STL versions.
Assignee | ||
Comment 1•4 years ago
|
||
Updated•4 years ago
|
Assignee | ||
Comment 2•4 years ago
|
||
Assignee | ||
Comment 3•4 years ago
|
||
Not sure if this is still wanted but put at patch up to show what changes it would take. Used tuple for UniquePtr to keep the compiler asserts passing otherwise pretty straightforward
Comment 4•4 years ago
|
||
Thanks for tackling this!
However, I am not sure if mozilla::Pair
should be completely removed. I guess https://groups.google.com/d/msg/mozilla.dev.platform/IQhGdhGxx2M/NpEHE7OguoIJ sounds like good advice in summary to me. Paraphrasing that:
- In general,
std::pair
should be preferred overmozilla::Pair
unless you need the empty type optimization. mozilla::Pair
should be renamed tomozilla::CompressedPair
to make the use case clearer.
Nathan, WDYT?
One more thing: you submitted two patches, which appear to do the same thing, but seem to be based on different base revisions? Could you abandon/mark one of those as obsolete?
Comment 5•4 years ago
|
||
Sorry, I missed the final part (i.e. https://groups.google.com/d/msg/mozilla.dev.platform/IQhGdhGxx2M/NJ99NV4gmfcJ) saying that mozilla::Tuple
(or does it refer to std::tuple
?) offers this empty type optimization as well? Then, maybe we can get rid of mozilla::Pair
entirely, and just check if there are cases that are better replaced by a tuple to benefit from empty type optimization.
![]() |
||
Comment 6•4 years ago
|
||
(In reply to Simon Giesecke [:sg] [he/him] from comment #4)
Thanks for tackling this!
However, I am not sure if
mozilla::Pair
should be completely removed. I guess https://groups.google.com/d/msg/mozilla.dev.platform/IQhGdhGxx2M/NpEHE7OguoIJ sounds like good advice in summary to me. Paraphrasing that:
- In general,
std::pair
should be preferred overmozilla::Pair
unless you need the empty type optimization.mozilla::Pair
should be renamed tomozilla::CompressedPair
to make the use case clearer.Nathan, WDYT?
This works for me. I have a slight preference for CompactPair
as the original post suggested instead of CompressedPair
, but since the number of use cases is expected to be relatively small, I don't think it matters that much.
Comment 7•4 years ago
|
||
(In reply to Nathan Froyd [:froydnj] from comment #6)
(In reply to Simon Giesecke [:sg] [he/him] from comment #4)
Thanks for tackling this!
However, I am not sure if
mozilla::Pair
should be completely removed. I guess https://groups.google.com/d/msg/mozilla.dev.platform/IQhGdhGxx2M/NpEHE7OguoIJ sounds like good advice in summary to me. Paraphrasing that:
- In general,
std::pair
should be preferred overmozilla::Pair
unless you need the empty type optimization.mozilla::Pair
should be renamed tomozilla::CompressedPair
to make the use case clearer.Nathan, WDYT?
This works for me. I have a slight preference for
CompactPair
as the original post suggested instead ofCompressedPair
, but since the number of use cases is expected to be relatively small, I don't think it matters that much.
Oh, this change was not intentional. Boost calls it boost::compressed_pair
, but in fact I'd prefer CompactPair
as well.
Updated•4 years ago
|
Updated•4 years ago
|
Updated•4 years ago
|
Assignee | ||
Comment 8•4 years ago
|
||
I've update the patch to rename to CompactPair and updated UniquePtr WasmOpIter.h back to use CompactPair. Let me know if there's any others you think should be switched back. Sorry for confusion with revision it updated the old one and not sure how to add reviewers back.
Updated•4 years ago
|
Updated•4 years ago
|
Updated•4 years ago
|
Pushed by nfroyd@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/a08637fb30c8 Rename mozilla::Pair to CompactPair. r=froydnj
Comment 10•4 years ago
|
||
Backed out changeset a08637fb30c8 (Bug 1143478) for causing bustages in /builds/worker/checkouts/gecko/ipc/mscom/Registration.cpp CLOSED TREE
https://treeherder.mozilla.org/logviewer.html#/jobs?job_id=292668381&repo=autoland&lineNumber=8633
Comment 11•4 years ago
|
||
Backout by shindli@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/7a6232e87e8f Backed out changeset a08637fb30c8 for causing bustages in /builds/worker/checkouts/gecko/ipc/mscom/Registration.cpp CLOSED TREE
Comment 12•4 years ago
|
||
Pushed by nfroyd@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/4db022e14a60 Rename mozilla::Pair to CompactPair. r=froydnj
Comment 13•4 years ago
|
||
bugherder |
Assignee | ||
Comment 14•4 years ago
|
||
This is just a commonly-used header causing sccache invalidations.
I think Nathan (froydnj) commented here already with above but if this is still issue or you need more info from me let me know
Description
•