Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(265)

Unified Diff: src/splay-tree-inl.h

Issue 10534006: Remove TLS access for current Zone. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Review. Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/splay-tree.h ('k') | src/stub-cache.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/splay-tree-inl.h
diff --git a/src/splay-tree-inl.h b/src/splay-tree-inl.h
index bb6ded7098b78d8f384e084e3d4adb88d9d6c7a7..b1fedecfe5bdb48fb54c61f66b08329497e2ec6e 100644
--- a/src/splay-tree-inl.h
+++ b/src/splay-tree-inl.h
@@ -36,8 +36,17 @@ namespace internal {
template<typename Config, class Allocator>
SplayTree<Config, Allocator>::~SplayTree() {
- NodeDeleter deleter;
- ForEachNode(&deleter);
+ // Pre-allocate some space for tiny trees. Since we don't have an
+ // Allocator object here, we allocate the list on the heap.
+ List<Node*> nodes_to_visit(10);
+ if (root_ != NULL) nodes_to_visit.Add(root_);
+ int pos = 0;
+ while (pos < nodes_to_visit.length()) {
+ Node* node = nodes_to_visit[pos++];
+ if (node->left() != NULL) nodes_to_visit.Add(node->left());
+ if (node->right() != NULL) nodes_to_visit.Add(node->right());
+ Allocator::Delete(node);
+ }
danno 2012/06/06 10:59:53 Store the allocator inside the splay tree so that
sanjoy 2012/06/06 11:43:54 Done.
}
@@ -286,9 +295,10 @@ void SplayTree<Config, Allocator>::Splay(const Key& key) {
template <typename Config, class Allocator> template <class Callback>
-void SplayTree<Config, Allocator>::ForEach(Callback* callback) {
+void SplayTree<Config, Allocator>::ForEach(Callback* callback,
+ Allocator allocator) {
NodeToPairAdaptor<Callback> callback_adaptor(callback);
- ForEachNode(&callback_adaptor);
+ ForEachNode(&callback_adaptor, allocator);
}
@@ -296,7 +306,7 @@ template <typename Config, class Allocator> template <class Callback>
void SplayTree<Config, Allocator>::ForEachNode(Callback* callback,
Allocator allocator) {
// Pre-allocate some space for tiny trees.
- List<Node*, Allocator> nodes_to_visit(10);
+ List<Node*, Allocator> nodes_to_visit(10, allocator);
if (root_ != NULL) nodes_to_visit.Add(root_, allocator);
int pos = 0;
while (pos < nodes_to_visit.length()) {
« no previous file with comments | « src/splay-tree.h ('k') | src/stub-cache.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698