Closed Bug 1843181 Opened 1 year ago Closed 1 year ago

EqualRange should return a std::pair, not a CompactPair

Categories

(Core :: MFBT, task, P5)

task

Tracking

()

RESOLVED FIXED
117 Branch
Tracking Status
firefox117 --- fixed

People

(Reporter: mstange, Assigned: mstange)

Details

Attachments

(1 file)

EqualRange currently returns a CompactPair:

https://searchfox.org/mozilla-central/rev/0b021daa5955f0288ef6477fc51be33f7f452f9a/mfbt/BinarySearch.h#218-221

template <typename Container, typename Comparator>
CompactPair<size_t, size_t> EqualRange(const Container& aContainer,
                                       size_t aBegin, size_t aEnd,
                                       const Comparator& aCompare) {

I don't think the reasons for preferring CompactPair over std::pair apply here. Using std::pair would be more ergonomic because you can do this:

auto [rangeStart, rangeEnd] = mozilla::EqualRange(...);

I didn't end up needing this change for anything, but I think it makes sense to do anyway.

mozilla::CompactPair doesn't seem appropriate because its base class optimization doesn't apply.

Pushed by mstange@themasta.com: https://hg.mozilla.org/integration/autoland/rev/801cb21ffbb0 Make EqualRange return a std::pair. r=sergesanspaille
Status: ASSIGNED → RESOLVED
Closed: 1 year ago
Resolution: --- → FIXED
Target Milestone: --- → 117 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: