Closed Bug 1417279 Opened 8 years ago Closed 8 years ago

Make nsArray::IndexOf a bit more sane

Categories

(Core :: XPCOM, enhancement)

enhancement
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla59
Tracking Status
firefox59 --- fixed

People

(Reporter: mrbkap, Assigned: mrbkap)

Details

Attachments

(1 file)

nsArray::IndexOf currently has two branches [1]: one that calls through to the under lying Array's implementation of IndexOf and one that uses EnumerateForward with a closure (and that enumerates every element anyway). This appears to be because nsArray used to be based on nsVoidArray, which only had an IndexOf that took an element to find and no start index. Fortunately, we now live in the future. nsVoidArray is long gone and nsArray's underlying implementation is based on nsTArray, which has all the variants that one could ever hope for. We can get rid of the odd second case in IndexOf. [1] https://searchfox.org/mozilla-central/rev/a662f122c37704456457a526af90db4e3c0fd10e/xpcom/ds/nsArray.cpp#84
Comment on attachment 8928341 [details] Bug 1417279 - Remove an odd second case from nsArray::IndexOf. https://reviewboard.mozilla.org/r/199550/#review204646 ::: commit-message-b2f45:3 (Diff revision 1) > +Bug 1417279 - Remove an odd second case from nsArray::IndexOf. r=froydnj > + > +Now that nsArray uses nsTArray under the hood, we don't have to do weird Nit: make this `nsCOMArray`, rather than `nsTArray`, perhaps? It's all `nsTArray` in the end, saying `nsCOMArray` would be a little clearer?
Attachment #8928341 - Flags: review?(nfroyd) → review+
Pushed by mrbkap@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/9ccc25047469 Remove an odd second case from nsArray::IndexOf. r=froydnj
Status: NEW → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla59
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: