diff --git a/mfbt/BinarySearch.h b/mfbt/BinarySearch.h index e5de93a259ef..f3aeac30a06e 100644 --- a/mfbt/BinarySearch.h +++ b/mfbt/BinarySearch.h @@ -8,9 +8,9 @@ #define mozilla_BinarySearch_h #include "mozilla/Assertions.h" -#include "mozilla/CompactPair.h" #include +#include namespace mozilla { @@ -216,9 +216,8 @@ size_t UpperBound(const Container& aContainer, size_t aBegin, size_t aEnd, } template -CompactPair EqualRange(const Container& aContainer, - size_t aBegin, size_t aEnd, - const Comparator& aCompare) { +std::pair EqualRange(const Container& aContainer, size_t aBegin, + size_t aEnd, const Comparator& aCompare) { MOZ_ASSERT(aBegin <= aEnd); size_t low = aBegin; @@ -235,13 +234,12 @@ CompactPair EqualRange(const Container& aContainer, } else if (result > 0) { low = middle + 1; } else { - return MakeCompactPair( - LowerBound(aContainer, low, middle, aCompare), - UpperBound(aContainer, middle + 1, high, aCompare)); + return {LowerBound(aContainer, low, middle, aCompare), + UpperBound(aContainer, middle + 1, high, aCompare)}; } } - return MakeCompactPair(low, high); + return {low, high}; } } // namespace mozilla diff --git a/mfbt/tests/TestBinarySearch.cpp b/mfbt/tests/TestBinarySearch.cpp index a81574b5c577..3cd28b309fbe 100644 --- a/mfbt/tests/TestBinarySearch.cpp +++ b/mfbt/tests/TestBinarySearch.cpp @@ -126,26 +126,26 @@ static void TestEqualRange() { for (int i = -1; i < kMaxNumber + 1; ++i) { auto bounds = EqualRange(sortedArray, 0, sortedArray.length(), CompareN(i)); - MOZ_RELEASE_ASSERT(bounds.first() <= sortedArray.length()); - MOZ_RELEASE_ASSERT(bounds.second() <= sortedArray.length()); - MOZ_RELEASE_ASSERT(bounds.first() <= bounds.second()); + MOZ_RELEASE_ASSERT(bounds.first <= sortedArray.length()); + MOZ_RELEASE_ASSERT(bounds.second <= sortedArray.length()); + MOZ_RELEASE_ASSERT(bounds.first <= bounds.second); - if (bounds.first() == 0) { + if (bounds.first == 0) { MOZ_RELEASE_ASSERT(sortedArray[0] >= i); - } else if (bounds.first() == sortedArray.length()) { + } else if (bounds.first == sortedArray.length()) { MOZ_RELEASE_ASSERT(sortedArray[sortedArray.length() - 1] < i); } else { - MOZ_RELEASE_ASSERT(sortedArray[bounds.first() - 1] < i); - MOZ_RELEASE_ASSERT(sortedArray[bounds.first()] >= i); + MOZ_RELEASE_ASSERT(sortedArray[bounds.first - 1] < i); + MOZ_RELEASE_ASSERT(sortedArray[bounds.first] >= i); } - if (bounds.second() == 0) { + if (bounds.second == 0) { MOZ_RELEASE_ASSERT(sortedArray[0] > i); - } else if (bounds.second() == sortedArray.length()) { + } else if (bounds.second == sortedArray.length()) { MOZ_RELEASE_ASSERT(sortedArray[sortedArray.length() - 1] <= i); } else { - MOZ_RELEASE_ASSERT(sortedArray[bounds.second() - 1] <= i); - MOZ_RELEASE_ASSERT(sortedArray[bounds.second()] > i); + MOZ_RELEASE_ASSERT(sortedArray[bounds.second - 1] <= i); + MOZ_RELEASE_ASSERT(sortedArray[bounds.second] > i); } } } diff --git a/toolkit/components/aboutthirdparty/AboutThirdParty.cpp b/toolkit/components/aboutthirdparty/AboutThirdParty.cpp index bf716e3bfb8a..73cef0d531df 100644 --- a/toolkit/components/aboutthirdparty/AboutThirdParty.cpp +++ b/toolkit/components/aboutthirdparty/AboutThirdParty.cpp @@ -796,11 +796,11 @@ NS_IMETHODIMP AboutThirdParty::LookupApplication( // If more than one application includes the module, we return null // because there is no way to know which is the real owner. - if (bounds.second() - bounds.first() != 1) { + if (bounds.second - bounds.first != 1) { return NS_OK; } - app = mLocations[bounds.first()].second(); + app = mLocations[bounds.first].second(); app.forget(aResult); return NS_OK; } diff --git a/toolkit/components/aboutthirdparty/tests/gtest/TestAboutThirdParty.cpp b/toolkit/components/aboutthirdparty/tests/gtest/TestAboutThirdParty.cpp index c8fb9c016f57..565e87e0f1db 100644 --- a/toolkit/components/aboutthirdparty/tests/gtest/TestAboutThirdParty.cpp +++ b/toolkit/components/aboutthirdparty/tests/gtest/TestAboutThirdParty.cpp @@ -115,11 +115,11 @@ TEST(AboutThirdParty, InstallLocations) for (const auto& testCase : kTestCases) { auto bounds = EqualRange(locations, 0, locations.Length(), InstallLocationComparator(testCase.mFile)); - if (bounds.second() - bounds.first() != 1) { + if (bounds.second - bounds.first != 1) { EXPECT_TRUE(testCase.mInstallPath.IsEmpty()); continue; } - EXPECT_EQ(locations[bounds.first()].first(), testCase.mInstallPath); + EXPECT_EQ(locations[bounds.first].first(), testCase.mInstallPath); } }