Bug 1613256 - Refactor EnsureSorted to use std::isSorted r=sg
authorSam Zeter <samuelzeter@gmail.com>
Sat, 22 Feb 2020 05:39:59 +0000
changeset 2648970 bd65ac107627408a01cf1faf62e59665ba37cf20
parent 2648969 039e8fd2928d8d368ad892fb065bb2471e13d86e
child 2648971 64a8e247759e18b560428a4ef6dbebd5a241fa22
child 2648972 b084269b612e3899949d1782dbe9fed7a0035410
child 2649005 c975595c90fbed980ab65a053f3b372ef294fbd4
child 2649012 ed647e425d9e09668392107964925b197fa76ff5
child 2649046 5899fdf070d9d727c60546c0cdc6b992e4058b8c
child 2649050 62395f79d34dd915ba62c1256021c996bf50ec1b
child 2649075 a721215f5275da901dffa7a141994e68b58c1aca
child 2649077 28b7ee4d82d512ddc41b80307d6b1e6b2b20a08e
child 2649079 e1cf5e71567cc1cb4866da55f6dfe37bb49459cf
child 2649084 f2a5dbcbbc699a903a6b298e5093abac8981d2e3
child 2649109 bc0f3594404d3eb811b374ea72dd47c19a0f4c70
child 2649113 708379fe8544c15f78bccc0be930ff3a5e4ce4c2
child 2649115 370384a63621948c8c30f37b7d3c1ecb0d57f952
child 2649119 b21faccabd7348a998c26a5c5dfdd084920f8942
child 2649144 ff178fc1b53c87d5843ead2ee9af4931f2e67717
child 2649212 959017b21d5f8bf378849942451d762ec02dc60a
child 2649214 09052a695ef9193a259fa832545734ff9919aa52
child 2649234 d3eb23a63af37584fafe8971d40c7e84e80d46d4
child 2649346 546df57b079951622d119b6f22a019a1c13bc6ba
child 2649403 8c3ad6c0dab30e4a317f90889a2eb45835a2738a
child 2649460 3a9c0367e02f6de22bf77383a658e7519f26e341
child 2649572 5af12a52f00f3b520ec960aafe85030dec098921
child 2653717 4ae2c9403accdd4fa42ab7bb3973099e95ca2663
child 2653719 1ced20f8ed1ebfb20e3708d765522e3f626d0a7e
child 2653767 d6a6d9f4e590553f9e09a97cb52e63d8df27afe7
child 2653769 72e1888959cc1647f4f996b5413d4edc754c0612
child 2654192 0512a9fe7e1237ec2c5df75f949b21b9ab08ef3a
child 2654196 1674bc86e657240b74f468a7d4c0d05d60824b5f
child 2657098 f276324d0346e4bedd964d97dab80fbc626a13f7
child 2657102 566a8a6beaed022d50a5f65f4bdbb8e0b436ef84
child 2657105 eef2cbec87cd8eeed9ddc37b9b8ffb189b89c915
child 2657250 0768afa58239069344cde8a05c76d4ead7f7a13e
child 2657253 9c83c4e8ab0c6ef5d48b59a4c231e593d5d7b926
child 2657255 b90be97a3749b09fe4ff8f91e4d3ac13865a0716
child 2661747 698c3ca4ca8895ca78d395bf71cf11a28d20fb67
child 2661750 9c2adf1492ee74710b3a3cc03b39dda5ba303915
child 2661752 a2c8cb766f7ca64e59bd629db5e9b834d7b8328b
push id490874
push userdvarga@mozilla.com
push dateSat, 22 Feb 2020 10:42:44 +0000
treeherdertry@64a8e247759e [default view] [failures only]
reviewerssg
bugs1613256
milestone75.0a1
Bug 1613256 - Refactor EnsureSorted to use std::isSorted r=sg Differential Revision: https://phabricator.services.mozilla.com/D62179
toolkit/components/url-classifier/VariableLengthPrefixSet.cpp
--- a/toolkit/components/url-classifier/VariableLengthPrefixSet.cpp
+++ b/toolkit/components/url-classifier/VariableLengthPrefixSet.cpp
@@ -27,30 +27,19 @@ static mozilla::LazyLogModule gUrlClassi
 namespace mozilla::safebrowsing {
 
 #define PREFIX_SIZE_FIXED 4
 
 #ifdef DEBUG
 namespace {
 
 template <class T>
-static void EnsureSorted(T* aArray) {
-  typename T::elem_type* start = aArray->Elements();
-  typename T::elem_type* end = aArray->Elements() + aArray->Length();
-  typename T::elem_type* iter = start;
-  typename T::elem_type* previous = start;
-
-  while (iter != end) {
-    previous = iter;
-    ++iter;
-    if (iter != end) {
-      MOZ_ASSERT(*previous <= *iter);
-    }
-  }
-  return;
+void EnsureSorted(T* aArray) {
+  MOZ_ASSERT(std::is_sorted(aArray->Elements(),
+                            aArray->Elements() + aArray->Length()));
 }
 
 }  // namespace
 #endif
 
 NS_IMPL_ISUPPORTS(VariableLengthPrefixSet, nsIMemoryReporter)
 
 // This class will process prefix size between 4~32. But for 4 bytes prefixes,