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

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

Issue 7374002: Refactor allocation policies. Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years, 5 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/string-stream.cc » ('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 9c2287eab7e98ca7c25401f8ed16635faa603698..effcec30c6c0677fa64290d0d301e9269b38de0c 100644
--- a/src/splay-tree-inl.h
+++ b/src/splay-tree-inl.h
@@ -36,7 +36,7 @@ namespace internal {
template<typename Config, class Allocator>
SplayTree<Config, Allocator>::~SplayTree() {
- NodeDeleter deleter;
+ NodeDeleter deleter(&allocator_);
ForEachNode(&deleter);
}
@@ -45,7 +45,7 @@ template<typename Config, class Allocator>
bool SplayTree<Config, Allocator>::Insert(const Key& key, Locator* locator) {
if (is_empty()) {
// If the tree is empty, insert the new node.
- root_ = new Node(key, Config::kNoValue);
+ root_ = new(&allocator_) Node(key, Config::kNoValue);
} else {
// Splay on the key to move the last node on the search path
// for the key to the root of the tree.
@@ -57,7 +57,7 @@ bool SplayTree<Config, Allocator>::Insert(const Key& key, Locator* locator) {
return false;
}
// Insert the new node.
- Node* node = new Node(key, Config::kNoValue);
+ Node* node = new(&allocator_) Node(key, Config::kNoValue);
InsertInternal(cmp, node);
}
locator->bind(root_);
@@ -183,7 +183,7 @@ bool SplayTree<Config, Allocator>::Move(const Key& old_key,
int cmp = Config::Compare(new_key, root_->key_);
if (cmp == 0) {
// A node with the target key already exists.
- delete node_to_move;
+ Node::Delete(&allocator_, node_to_move);
return false;
}
node_to_move->key_ = new_key;
@@ -198,7 +198,7 @@ bool SplayTree<Config, Allocator>::Remove(const Key& key) {
return false;
Node* node_to_remove = root_;
RemoveRootNode(key);
- delete node_to_remove;
+ Node::Delete(&allocator_, node_to_remove);
return true;
}
@@ -293,7 +293,7 @@ void SplayTree<Config, Allocator>::ForEach(Callback* callback) {
template <typename Config, class Allocator> template <class Callback>
void SplayTree<Config, Allocator>::ForEachNode(Callback* callback) {
// 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_);
int pos = 0;
while (pos < nodes_to_visit.length()) {
« no previous file with comments | « src/splay-tree.h ('k') | src/string-stream.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698