Add an iplist::clearAndLeakNodesUnsafely() function.
[oota-llvm.git] / include / llvm / ADT / ilist.h
index 36650d43750ceff917078028cee627db6fe9681a..20cdae32554a7eed6854cc756e7f5928bf5b3f96 100644 (file)
@@ -465,6 +465,17 @@ public:
     return where;
   }
 
+  /// Remove all nodes from the list like clear(), but do not call
+  /// removeNodeFromList() or deleteNode().
+  ///
+  /// This should only be used immediately before freeing nodes in bulk to
+  /// avoid traversing the list and bringing all the nodes into cache.
+  void clearAndLeakNodesUnsafely() {
+    if (Head) {
+      Head = getTail();
+      this->setPrev(Head, Head);
+    }
+  }
 
 private:
   // transfer - The heart of the splice function.  Move linked list nodes from