Open Bug 1486941 Opened Last year
TArray::Index Of(...) != No Index` patterns with `ns TArray::Contains`
There are quite a few places where some code wants to know if an array contains a particular element, and it is done with something like `array.IndexOf(element) != decltype(array)::NoIndex`. Instead, these searches should now be done with `array.Contains(element)`. The main reasons are: - `Contains` is now more efficient than `IndexOf!=NoIndex`, as it doesn't compute an index and then compares it to NoIndex; instead it directly returns true when the element is found, or false otherwise. See bug 1479996 for details. - "Contains" is shorter, and conveys a clearer intent than "Find an index and compare to no-index". Sometimes the IndexOf value is compared to NoIndex, and then reused to actually work on the element. This is generally fine to keep, as the index computation is not wasted; a subset could possibly be replaced with nsTArray::ApplyIf, TBD.
You need to log in before you can comment on or make changes to this bug.