|
template<class _CharT , class _Alloc >
Definition at line 208 of file _rope.c. {
int __current_index = __x._M_leaf_index;
const _RopeRep* __current_node = __x._M_path_end._M_data[__current_index];
size_t __len = __current_node->_M_size._M_data;
size_t __node_start_pos = __x._M_leaf_pos;
unsigned char __dirns = __x._M_path_directions;
const _RopeConcat* __c;
_STLP_ASSERT(__x._M_current_pos <= __x._M_root->_M_size._M_data)
if (__x._M_current_pos - __node_start_pos < __len) {
/* More stuff in this leaf, we just didn't cache it. */
_S_setbuf(__x);
return;
}
_STLP_ASSERT(__node_start_pos + __len == __x._M_current_pos)
// node_start_pos is starting position of last_node.
while (--__current_index >= 0) {
if (!(__dirns & 1) /* Path turned left */)
break;
__current_node = __x._M_path_end._M_data[__current_index];
__c = __STATIC_CAST(const _RopeConcat*, __current_node);
// Otherwise we were in the right child. Thus we should pop
// the concatenation node.
__node_start_pos -= __c->_M_left->_M_size._M_data;
__dirns >>= 1;
}
if (__current_index < 0) {
// We underflowed the cache. Punt.
_S_setcache(__x);
return;
}
__current_node = __x._M_path_end._M_data[__current_index];
__c = __STATIC_CAST(const _RopeConcat*, __current_node);
// current_node is a concatenation node. We are positioned on the first
// character in its right child.
// node_start_pos is starting position of current_node.
__node_start_pos += __c->_M_left->_M_size._M_data;
__current_node = __c->_M_right;
__x._M_path_end._M_data[++__current_index] = __current_node;
__dirns |= 1;
while (_RopeRep::_S_concat == __current_node->_M_tag) {
++__current_index;
if (_S_path_cache_len == __current_index) {
int __i;
for (__i = 0; __i < _S_path_cache_len-1; ++__i) {
__x._M_path_end._M_data[__i] = __x._M_path_end._M_data[__i+1];
}
--__current_index;
}
__current_node = __STATIC_CAST(const _RopeConcat*, __current_node)->_M_left;
__x._M_path_end._M_data[__current_index] = __current_node;
__dirns <<= 1;
// node_start_pos is unchanged.
}
__x._M_leaf_index = __current_index;
__x._M_leaf_pos = __node_start_pos;
__x._M_path_directions = __dirns;
_S_setbuf(__x);
}
|