- Some last minute performance improvements I noticed.
This commit is contained in:
@@ -226,7 +226,7 @@ public:
|
||||
/// \param i The node id
|
||||
/// \returns `true` if `i` is the right node of `parent(i)`, `false` otherwise
|
||||
constexpr bool direction(size_t i) const {
|
||||
return i == npos ? false : i == right(parent(i));
|
||||
return i == npos ? false : i == right(_parent(i));
|
||||
}
|
||||
|
||||
///
|
||||
@@ -242,7 +242,7 @@ public:
|
||||
}
|
||||
size_t p = _parent(i);
|
||||
bool d = i == _right(p);
|
||||
return _child(p, d);
|
||||
return _child(p, !d);
|
||||
}
|
||||
|
||||
///
|
||||
@@ -405,7 +405,7 @@ public:
|
||||
_parent(new_root) = sub_parent;
|
||||
_parent(sub) = new_root;
|
||||
if (sub_parent != npos) {
|
||||
_child(sub_parent, sub == right(sub_parent)) = new_root;
|
||||
_child(sub_parent, sub == _right(sub_parent)) = new_root;
|
||||
} else {
|
||||
_root = new_root;
|
||||
}
|
||||
@@ -579,8 +579,8 @@ public:
|
||||
};
|
||||
|
||||
struct in_order {
|
||||
list<size_t> visit;
|
||||
size_t head;
|
||||
list<size_t> visit;
|
||||
|
||||
constexpr size_t operator()(const bintree& tree, size_t start) {
|
||||
head = start;
|
||||
@@ -683,9 +683,8 @@ public:
|
||||
|
||||
constexpr iterator(bintree* tree, size_t root, size_t node)
|
||||
: _tree(tree)
|
||||
, _order()
|
||||
, _order(root)
|
||||
, _n(node) {
|
||||
_order(*tree, root);
|
||||
}
|
||||
|
||||
size_t index() const {
|
||||
@@ -805,7 +804,7 @@ protected:
|
||||
}
|
||||
|
||||
constexpr size_t& _grandparent(size_t i) {
|
||||
return _parent(parent(i));
|
||||
return _parent(_parent(i));
|
||||
}
|
||||
|
||||
constexpr size_t& _left(size_t i) {
|
||||
@@ -821,10 +820,9 @@ protected:
|
||||
}
|
||||
|
||||
constexpr size_t& _sibling(size_t i) {
|
||||
size_t p = _parent(i);
|
||||
size_t& l = _left(p);
|
||||
size_t& r = _right(p);
|
||||
return i == l ? l : r;
|
||||
size_t p = _parent(i);
|
||||
bool d = i == _right(p);
|
||||
return _child(p, !d);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user