Title: [239021] trunk/Source/WTF
Revision
239021
Author
[email protected]
Date
2018-12-09 08:43:02 -0800 (Sun, 09 Dec 2018)

Log Message

Unreviewed, fix build failure on GCC 8.2, part 2

Add RefCountedArray::assign, and use it instead of operator= internally.
We should have operator=(const RefCountedArray&) since it will be automatically generated
if we do not have correct implementation here.

* wtf/RefCountedArray.h:
(WTF::RefCountedArray::operator=):
(WTF::RefCountedArray::assign):

Modified Paths

Diff

Modified: trunk/Source/WTF/ChangeLog (239020 => 239021)


--- trunk/Source/WTF/ChangeLog	2018-12-09 16:09:07 UTC (rev 239020)
+++ trunk/Source/WTF/ChangeLog	2018-12-09 16:43:02 UTC (rev 239021)
@@ -1,5 +1,17 @@
 2018-12-09  Yusuke Suzuki  <[email protected]>
 
+        Unreviewed, fix build failure on GCC 8.2, part 2
+
+        Add RefCountedArray::assign, and use it instead of operator= internally.
+        We should have operator=(const RefCountedArray&) since it will be automatically generated
+        if we do not have correct implementation here.
+
+        * wtf/RefCountedArray.h:
+        (WTF::RefCountedArray::operator=):
+        (WTF::RefCountedArray::assign):
+
+2018-12-09  Yusuke Suzuki  <[email protected]>
+
         Unreviewed, fix build failure on GCC 8.2
 
         We remove operator=<PtrTraits> call since it is not necessary.

Modified: trunk/Source/WTF/wtf/RefCountedArray.h (239020 => 239021)


--- trunk/Source/WTF/wtf/RefCountedArray.h	2018-12-09 16:09:07 UTC (rev 239020)
+++ trunk/Source/WTF/wtf/RefCountedArray.h	2018-12-09 16:43:02 UTC (rev 239021)
@@ -105,19 +105,12 @@
     template<typename OtherTraits = PtrTraits>
     RefCountedArray& operator=(const RefCountedArray<T, OtherTraits>& other)
     {
-        T* oldData = data();
-        T* otherData = const_cast<T*>(other.data());
-        if (otherData)
-            Header::fromPayload(otherData)->refCount++;
-        m_data = otherData;
+        return assign<OtherTraits>(other);
+    }
 
-        if (!oldData)
-            return *this;
-        if (--Header::fromPayload(oldData)->refCount)
-            return *this;
-        VectorTypeOperations<T>::destruct(oldData, oldData + Header::fromPayload(oldData)->length);
-        fastFree(Header::fromPayload(oldData));
-        return *this;
+    RefCountedArray& operator=(const RefCountedArray& other)
+    {
+        return assign<PtrTraits>(other);
     }
 
     ~RefCountedArray()
@@ -198,6 +191,24 @@
     bool operator==(const RefCountedArray& other) const { return this->operator==<PtrTraits>(other); }
     
 private:
+    template<typename OtherTraits = PtrTraits>
+    RefCountedArray& assign(const RefCountedArray<T, OtherTraits>& other)
+    {
+        T* oldData = data();
+        T* otherData = const_cast<T*>(other.data());
+        if (otherData)
+            Header::fromPayload(otherData)->refCount++;
+        m_data = otherData;
+
+        if (!oldData)
+            return *this;
+        if (--Header::fromPayload(oldData)->refCount)
+            return *this;
+        VectorTypeOperations<T>::destruct(oldData, oldData + Header::fromPayload(oldData)->length);
+        fastFree(Header::fromPayload(oldData));
+        return *this;
+    }
+
     struct Header {
         unsigned refCount;
         unsigned length;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to