From c4a1df6e914a1e30c0ff19b8010262953138361a Mon Sep 17 00:00:00 2001 From: artemp Date: Tue, 15 Aug 2017 11:13:11 +0100 Subject: [PATCH] simplify impl + const correctness + minor cleanup --- include/mapnik/quad_tree.hpp | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/include/mapnik/quad_tree.hpp b/include/mapnik/quad_tree.hpp index 9b2af5d5e..b6f2747bc 100644 --- a/include/mapnik/quad_tree.hpp +++ b/include/mapnik/quad_tree.hpp @@ -117,7 +117,7 @@ public: root_ = nodes_[0].get(); } - void insert(value_type data, bbox_type const& box) + void insert(value_type const& data, bbox_type const& box) { unsigned int depth = 0; do_insert_data(data, box, root_, depth); @@ -207,13 +207,9 @@ private: } } - void do_insert_data(value_type data, bbox_type const& box, node * n, unsigned int& depth) + void do_insert_data(value_type const& data, bbox_type const& box, node * n, unsigned int& depth) { - if (++depth >= max_depth_) - { - n->cont_.push_back(data); - } - else + if (++depth < max_depth_) { bbox_type const& node_extent = n->extent(); bbox_type ext[4]; @@ -225,17 +221,17 @@ private: if (!n->children_[i]) { nodes_.push_back(std::make_unique(ext[i])); - n->children_[i]=nodes_.back().get(); + n->children_[i] = nodes_.back().get(); } - do_insert_data(data,box,n->children_[i],depth); + do_insert_data(data, box, n->children_[i], depth); return; } } - n->cont_.push_back(data); } + n->cont_.push_back(data); } - void split_box(bbox_type const& node_extent,bbox_type * ext) + void split_box(bbox_type const& node_extent, bbox_type * ext) { typename bbox_type::value_type width = node_extent.width(); typename bbox_type::value_type height = node_extent.height();