summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorJakob Stoklund Olesen <stoklund@2pi.dk>2013-01-04 22:35:42 +0000
committerJakob Stoklund Olesen <stoklund@2pi.dk>2013-01-04 22:35:42 +0000
commit7c5c12bd4d60070c90161df9f6ae078c1f7b1ce5 (patch)
tree05f4b712a6801534c291d7b61398122f474d2bea /include
parent73a853f05c913f6127e93cf0df3ba6398bcfc213 (diff)
downloadllvm-7c5c12bd4d60070c90161df9f6ae078c1f7b1ce5.tar.gz
llvm-7c5c12bd4d60070c90161df9f6ae078c1f7b1ce5.tar.bz2
llvm-7c5c12bd4d60070c90161df9f6ae078c1f7b1ce5.tar.xz
Add an iplist::clearAndLeakNodesUnsafely() function.
The iplist::clear() function can be quite expensive because it traverses the entire list, calling deleteNode() and removeNodeFromList() on each element. If node destruction and deallocation can be handled some other way, clearAndLeakNodesUnsafely() can be used to jettison all nodes without bringing them into cache. The function name is meant to be ominous. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171540 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r--include/llvm/ADT/ilist.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/include/llvm/ADT/ilist.h b/include/llvm/ADT/ilist.h
index 36650d4375..20cdae3255 100644
--- a/include/llvm/ADT/ilist.h
+++ b/include/llvm/ADT/ilist.h
@@ -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