exec_node: Add insert_before that inserts an entire list
authorIan Romanick <ian.d.romanick@intel.com>
Fri, 27 Aug 2010 20:53:56 +0000 (13:53 -0700)
committerIan Romanick <ian.d.romanick@intel.com>
Fri, 3 Sep 2010 18:55:21 +0000 (11:55 -0700)
src/glsl/list.h

index 764777431067f8f9067041b8421464252ea2b52d..69cf9935f86fef9a5121c9620764a0d85588a486 100644 (file)
@@ -165,6 +165,12 @@ struct exec_node {
       this->prev->next = before;
       this->prev = before;
    }
+
+   /**
+    * Insert another list in the list before the current node
+    */
+   void insert_before(class exec_list *before);
+
    /**
     * Replace the current node with the given node.
     */
@@ -449,6 +455,23 @@ struct exec_list {
 #endif
 };
 
+
+#ifdef __cplusplus
+inline void exec_node::insert_before(exec_list *before)
+{
+   if (before->is_empty())
+      return;
+
+   before->tail_pred->next = this;
+   before->head->prev = this->prev;
+
+   this->prev->next = before->head;
+   this->prev = before->tail_pred;
+
+   before->make_empty();
+}
+#endif
+
 /**
  * This version is safe even if the current node is removed.
  */