Title: [161349] trunk/Source/WTF
Revision
161349
Author
[email protected]
Date
2014-01-06 09:41:25 -0800 (Mon, 06 Jan 2014)

Log Message

DoublyLinkedLists can't be concatenated
https://bugs.webkit.org/show_bug.cgi?id=125976

Reviewed by Filip Pizlo.

* wtf/DoublyLinkedList.h:
(WTF::DoublyLinkedList<T>::append):

Modified Paths

Diff

Modified: trunk/Source/WTF/ChangeLog (161348 => 161349)


--- trunk/Source/WTF/ChangeLog	2014-01-06 17:37:26 UTC (rev 161348)
+++ trunk/Source/WTF/ChangeLog	2014-01-06 17:41:25 UTC (rev 161349)
@@ -1,3 +1,13 @@
+2014-01-03  Mark Hahnenberg  <[email protected]>
+
+        DoublyLinkedLists can't be concatenated
+        https://bugs.webkit.org/show_bug.cgi?id=125976
+
+        Reviewed by Filip Pizlo.
+
+        * wtf/DoublyLinkedList.h:
+        (WTF::DoublyLinkedList<T>::append):
+
 2014-01-04  Zan Dobersek  <[email protected]>
 
         Explicitly use the std:: nested name specifier when using std::pair, std::make_pair

Modified: trunk/Source/WTF/wtf/DoublyLinkedList.h (161348 => 161349)


--- trunk/Source/WTF/wtf/DoublyLinkedList.h	2014-01-06 17:37:26 UTC (rev 161348)
+++ trunk/Source/WTF/wtf/DoublyLinkedList.h	2014-01-06 17:41:25 UTC (rev 161349)
@@ -82,6 +82,7 @@
     void push(T*);
     void append(T*);
     void remove(T*);
+    void append(DoublyLinkedList<T>&);
 
 private:
     T* m_head;
@@ -186,6 +187,31 @@
     return node;
 }
 
+template<typename T> inline void DoublyLinkedList<T>::append(DoublyLinkedList<T>& other)
+{
+    if (!other.head())
+        return;
+
+    if (!head()) {
+        m_head = other.head();
+        m_tail = other.tail();
+        other.clear();
+        return;
+    }
+
+    ASSERT(tail());
+    ASSERT(other.head());
+    T* otherHead = other.head();
+    T* otherTail = other.tail();
+    other.clear();
+
+    ASSERT(!m_tail->next());
+    m_tail->setNext(otherHead);
+    ASSERT(!otherHead->prev());
+    otherHead->setPrev(m_tail);
+    m_tail = otherTail;
+}
+
 } // namespace WTF
 
 using WTF::DoublyLinkedListNode;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to