operator==(Vector, Vector) should work with different inline capacities
authorantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 22 Oct 2019 15:18:43 +0000 (15:18 +0000)
committerantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 22 Oct 2019 15:18:43 +0000 (15:18 +0000)
https://bugs.webkit.org/show_bug.cgi?id=203245

Reviewed by Alex Christensen.

Source/WTF:

Also allow different overflow behavior and minimum capacity.

* wtf/Vector.h:
(WTF::operator==):
(WTF::operator!=):

Tools:

* TestWebKitAPI/Tests/WTF/Vector.cpp:
(TestWebKitAPI::TEST):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@251432 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WTF/ChangeLog
Source/WTF/wtf/Vector.h
Tools/ChangeLog
Tools/TestWebKitAPI/Tests/WTF/Vector.cpp

index 20dc622..2203519 100644 (file)
@@ -1,3 +1,16 @@
+2019-10-22  Antti Koivisto  <antti@apple.com>
+
+        operator==(Vector, Vector) should work with different inline capacities
+        https://bugs.webkit.org/show_bug.cgi?id=203245
+
+        Reviewed by Alex Christensen.
+
+        Also allow different overflow behavior and minimum capacity.
+
+        * wtf/Vector.h:
+        (WTF::operator==):
+        (WTF::operator!=):
+
 2019-10-22  Rob Buis  <rbuis@igalia.com>
 
         https://bugs.webkit.org/show_bug.cgi?id=169667
index a4ed6ee..051396d 100644 (file)
@@ -1591,8 +1591,8 @@ inline void swap(Vector<T, inlineCapacity, OverflowHandler, minCapacity>& a, Vec
     a.swap(b);
 }
 
-template<typename T, size_t inlineCapacity, typename OverflowHandler, size_t minCapacity>
-bool operator==(const Vector<T, inlineCapacity, OverflowHandler, minCapacity>& a, const Vector<T, inlineCapacity, OverflowHandler, minCapacity>& b)
+template<typename T, size_t inlineCapacityA, typename OverflowHandlerA, size_t minCapacityA, size_t inlineCapacityB, typename OverflowHandlerB, size_t minCapacityB>
+bool operator==(const Vector<T, inlineCapacityA, OverflowHandlerA, minCapacityA>& a, const Vector<T, inlineCapacityB, OverflowHandlerB, minCapacityB>& b)
 {
     if (a.size() != b.size())
         return false;
@@ -1600,8 +1600,8 @@ bool operator==(const Vector<T, inlineCapacity, OverflowHandler, minCapacity>& a
     return VectorTypeOperations<T>::compare(a.data(), b.data(), a.size());
 }
 
-template<typename T, size_t inlineCapacity, typename OverflowHandler, size_t minCapacity>
-inline bool operator!=(const Vector<T, inlineCapacity, OverflowHandler, minCapacity>& a, const Vector<T, inlineCapacity, OverflowHandler, minCapacity>& b)
+template<typename T, size_t inlineCapacityA, typename OverflowHandlerA, size_t minCapacityA, size_t inlineCapacityB, typename OverflowHandlerB, size_t minCapacityB>
+inline bool operator!=(const Vector<T, inlineCapacityA, OverflowHandlerA, minCapacityA>& a, const Vector<T, inlineCapacityB, OverflowHandlerB, minCapacityB>& b)
 {
     return !(a == b);
 }
index 093560c..9d67d76 100644 (file)
@@ -1,3 +1,13 @@
+2019-10-22  Antti Koivisto  <antti@apple.com>
+
+        operator==(Vector, Vector) should work with different inline capacities
+        https://bugs.webkit.org/show_bug.cgi?id=203245
+
+        Reviewed by Alex Christensen.
+
+        * TestWebKitAPI/Tests/WTF/Vector.cpp:
+        (TestWebKitAPI::TEST):
+
 2019-10-22  Carlos Alberto Lopez Perez  <clopez@igalia.com>
 
         Add a script to run ImageDiff manually
index 69979e3..1da29c1 100644 (file)
@@ -156,6 +156,9 @@ TEST(WTF_Vector, InitializeFromOtherInitialCapacity)
     EXPECT_EQ(3, vectorCopy[1]);
     EXPECT_EQ(2, vectorCopy[2]);
     EXPECT_EQ(4, vectorCopy[3]);
+
+    EXPECT_TRUE(vector == vectorCopy);
+    EXPECT_FALSE(vector != vectorCopy);
 }
 
 TEST(WTF_Vector, CopyFromOtherInitialCapacity)
@@ -175,6 +178,9 @@ TEST(WTF_Vector, CopyFromOtherInitialCapacity)
     EXPECT_EQ(3, vectorCopy[1]);
     EXPECT_EQ(2, vectorCopy[2]);
     EXPECT_EQ(4, vectorCopy[3]);
+
+    EXPECT_TRUE(vector == vectorCopy);
+    EXPECT_FALSE(vector != vectorCopy);
 }
 
 TEST(WTF_Vector, InitializeFromOtherOverflowBehavior)
@@ -188,6 +194,9 @@ TEST(WTF_Vector, InitializeFromOtherOverflowBehavior)
     EXPECT_EQ(3, vectorCopy[1]);
     EXPECT_EQ(2, vectorCopy[2]);
     EXPECT_EQ(1, vectorCopy[3]);
+
+    EXPECT_TRUE(vector == vectorCopy);
+    EXPECT_FALSE(vector != vectorCopy);
 }
 
 TEST(WTF_Vector, CopyFromOtherOverflowBehavior)
@@ -207,6 +216,9 @@ TEST(WTF_Vector, CopyFromOtherOverflowBehavior)
     EXPECT_EQ(3, vectorCopy[1]);
     EXPECT_EQ(2, vectorCopy[2]);
     EXPECT_EQ(1, vectorCopy[3]);
+
+    EXPECT_TRUE(vector == vectorCopy);
+    EXPECT_FALSE(vector != vectorCopy);
 }
 
 TEST(WTF_Vector, InitializeFromOtherMinCapacity)
@@ -220,6 +232,9 @@ TEST(WTF_Vector, InitializeFromOtherMinCapacity)
     EXPECT_EQ(4, vectorCopy[1]);
     EXPECT_EQ(2, vectorCopy[2]);
     EXPECT_EQ(1, vectorCopy[3]);
+
+    EXPECT_TRUE(vector == vectorCopy);
+    EXPECT_FALSE(vector != vectorCopy);
 }
 
 TEST(WTF_Vector, CopyFromOtherMinCapacity)
@@ -239,6 +254,9 @@ TEST(WTF_Vector, CopyFromOtherMinCapacity)
     EXPECT_EQ(4, vectorCopy[1]);
     EXPECT_EQ(2, vectorCopy[2]);
     EXPECT_EQ(1, vectorCopy[3]);
+
+    EXPECT_TRUE(vector == vectorCopy);
+    EXPECT_FALSE(vector != vectorCopy);
 }
 
 TEST(WTF_Vector, Reverse)