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

Unified Diff: cc/base/rtree.cc

Issue 2570393002: cc: Change Nodes collection to use base::ContiguousContainer instead of deque. (Closed)
Patch Set: update Created 4 years 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 | « cc/base/rtree.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/base/rtree.cc
diff --git a/cc/base/rtree.cc b/cc/base/rtree.cc
index 0b389f427fe8e74b65242d29db1e2dbca0f009f7..ce0af9da572a6096a951a390dbebf3419b79eb04 100644
--- a/cc/base/rtree.cc
+++ b/cc/base/rtree.cc
@@ -10,16 +10,16 @@
#include <cmath>
#include "base/logging.h"
+#include "base/numerics/saturated_arithmetic.h"
namespace cc {
-RTree::RTree() : num_data_elements_(0u) {}
+RTree::RTree() : num_data_elements_(0u), nodes_(sizeof(Node)) {}
RTree::~RTree() {}
RTree::Node* RTree::AllocateNodeAtLevel(int level) {
- nodes_.push_back(Node());
- Node& node = nodes_.back();
+ Node& node = nodes_.AllocateAndConstruct<Node>();
node.num_children = 0;
node.level = level;
return &node;
@@ -76,13 +76,25 @@ RTree::Branch RTree::BuildRecursive(std::vector<Branch>* branches, int level) {
branch.bounds = (*branches)[current_branch].bounds;
branch.subtree = node;
++current_branch;
+ int x = branch.bounds.x();
+ int y = branch.bounds.y();
+ int right = branch.bounds.right();
+ int bottom = branch.bounds.bottom();
for (int k = 1; k < increment_by && current_branch < branches->size();
++k) {
- branch.bounds.Union((*branches)[current_branch].bounds);
+ auto& bounds = (*branches)[current_branch].bounds;
danakj 2016/12/16 14:36:22 leave a comment why you're writing union out
vmpstr 2016/12/16 18:57:52 Done.
+ x = std::min(x, bounds.x());
+ y = std::min(y, bounds.y());
+ right = std::max(right, bounds.right());
+ bottom = std::max(bottom, bounds.bottom());
+
node->children[k] = (*branches)[current_branch];
++node->num_children;
++current_branch;
}
+ branch.bounds.SetRect(x, y, base::SaturatedSubtraction(right, x),
+ base::SaturatedSubtraction(bottom, y));
+
DCHECK_LT(new_branch_index, current_branch);
(*branches)[new_branch_index] = branch;
++new_branch_index;
« no previous file with comments | « cc/base/rtree.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698