@@ -2151,50 +2151,54 @@ auto btree_iterator<N, R, P>::distance_slow(const_iterator other) const
21512151
21522152template <typename N, typename R, typename P>
21532153void btree_iterator<N, R, P>::increment_slow() {
2154- if (node_->is_leaf ()) {
2155- assert (position_ >= node_->finish ());
2156- btree_iterator save (*this );
2157- while (position_ == node_->finish () && !node_->is_root ()) {
2158- assert (node_->parent ()->child (node_->position ()) == node_);
2159- position_ = node_->position ();
2160- node_ = node_->parent ();
2154+ N* node = node_;
2155+ int position = position_;
2156+ if (node->is_leaf ()) {
2157+ assert (position >= node->finish ());
2158+ while (position == node->finish () && !node->is_root ()) {
2159+ assert (node->parent ()->child (node->position ()) == node);
2160+ position = node->position ();
2161+ node = node->parent ();
21612162 }
21622163 // TODO(ezb): assert we aren't incrementing end() instead of handling.
2163- if (position_ == node_ ->finish ()) {
2164- * this = save ;
2164+ if (position == node ->finish ()) {
2165+ return ;
21652166 }
21662167 } else {
2167- assert (position_ < node_ ->finish ());
2168- node_ = node_ ->child (static_cast <field_type>(position_ + 1 ));
2169- while (node_ ->is_internal ()) {
2170- node_ = node_ ->start_child ();
2168+ assert (position < node ->finish ());
2169+ node = node ->child (static_cast <field_type>(position + 1 ));
2170+ while (node ->is_internal ()) {
2171+ node = node ->start_child ();
21712172 }
2172- position_ = node_ ->start ();
2173+ position = node ->start ();
21732174 }
2175+ *this = {node, position};
21742176}
21752177
21762178template <typename N, typename R, typename P>
21772179void btree_iterator<N, R, P>::decrement_slow() {
2178- if (node_->is_leaf ()) {
2179- assert (position_ <= -1 );
2180- btree_iterator save (*this );
2181- while (position_ < node_->start () && !node_->is_root ()) {
2182- assert (node_->parent ()->child (node_->position ()) == node_);
2183- position_ = node_->position () - 1 ;
2184- node_ = node_->parent ();
2180+ N* node = node_;
2181+ int position = position_;
2182+ if (node->is_leaf ()) {
2183+ assert (position <= -1 );
2184+ while (position < node->start () && !node->is_root ()) {
2185+ assert (node->parent ()->child (node->position ()) == node);
2186+ position = node->position () - 1 ;
2187+ node = node->parent ();
21852188 }
21862189 // TODO(ezb): assert we aren't decrementing begin() instead of handling.
2187- if (position_ < node_ ->start ()) {
2188- * this = save ;
2190+ if (position < node ->start ()) {
2191+ return ;
21892192 }
21902193 } else {
2191- assert (position_ >= node_ ->start ());
2192- node_ = node_ ->child (static_cast <field_type>(position_ ));
2193- while (node_ ->is_internal ()) {
2194- node_ = node_ ->child (node_ ->finish ());
2194+ assert (position >= node ->start ());
2195+ node = node ->child (static_cast <field_type>(position ));
2196+ while (node ->is_internal ()) {
2197+ node = node ->child (node ->finish ());
21952198 }
2196- position_ = node_ ->finish () - 1 ;
2199+ position = node ->finish () - 1 ;
21972200 }
2201+ *this = {node, position};
21982202}
21992203
22002204template <typename N, typename R, typename P>
0 commit comments