Cleanup
This commit is contained in:
@@ -39,15 +39,15 @@ void LineIterator::seek_line(uint32_t line_index) {
|
|||||||
descend(root);
|
descend(root);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
uint32_t nth = line_index; // we want the position right after the nth '\n' (1-indexed)
|
uint32_t nth = line_index;
|
||||||
Shard *s = root;
|
Shard *s = root;
|
||||||
while (s->kind == Shard::ShardKind::Branch) {
|
while (s->kind == Shard::ShardKind::Branch) {
|
||||||
auto *b = static_cast<Branch *>(s);
|
auto *b = static_cast<Branch *>(s);
|
||||||
if (nth <= b->left->lines) {
|
if (nth <= b->left->lines) {
|
||||||
stack.push_back(b); // still need to visit b->right later
|
stack.push_back(b);
|
||||||
s = b->left;
|
s = b->left;
|
||||||
} else {
|
} else {
|
||||||
nth -= b->left->lines; // left fully skipped, don't revisit it
|
nth -= b->left->lines;
|
||||||
s = b->right;
|
s = b->right;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user