sum_tree: Store context on cursor (#34904)
This gets rid of the need to pass context to all cursor functions. In practice context is always immutable when interacting with cursors. A nicety of this is in the follow-up PR we will be able to implement Iterator for all Cursors/filter cursors (hell, we may be able to get rid of filter cursor altogether, as it is just a custom `filter` impl on iterator trait). Release Notes: - N/A
This commit is contained in:
@@ -296,7 +296,7 @@ impl GitBlame {
|
||||
let row = info
|
||||
.buffer_row
|
||||
.filter(|_| info.buffer_id == Some(buffer_id))?;
|
||||
cursor.seek_forward(&row, Bias::Right, &());
|
||||
cursor.seek_forward(&row, Bias::Right);
|
||||
cursor.item()?.blame.clone()
|
||||
})
|
||||
}
|
||||
@@ -389,7 +389,7 @@ impl GitBlame {
|
||||
}
|
||||
}
|
||||
|
||||
new_entries.append(cursor.slice(&edit.old.start, Bias::Right, &()), &());
|
||||
new_entries.append(cursor.slice(&edit.old.start, Bias::Right), &());
|
||||
|
||||
if edit.new.start > new_entries.summary().rows {
|
||||
new_entries.push(
|
||||
@@ -401,7 +401,7 @@ impl GitBlame {
|
||||
);
|
||||
}
|
||||
|
||||
cursor.seek(&edit.old.end, Bias::Right, &());
|
||||
cursor.seek(&edit.old.end, Bias::Right);
|
||||
if !edit.new.is_empty() {
|
||||
new_entries.push(
|
||||
GitBlameEntry {
|
||||
@@ -412,7 +412,7 @@ impl GitBlame {
|
||||
);
|
||||
}
|
||||
|
||||
let old_end = cursor.end(&());
|
||||
let old_end = cursor.end();
|
||||
if row_edits
|
||||
.peek()
|
||||
.map_or(true, |next_edit| next_edit.old.start >= old_end)
|
||||
@@ -421,18 +421,18 @@ impl GitBlame {
|
||||
if old_end > edit.old.end {
|
||||
new_entries.push(
|
||||
GitBlameEntry {
|
||||
rows: cursor.end(&()) - edit.old.end,
|
||||
rows: cursor.end() - edit.old.end,
|
||||
blame: entry.blame.clone(),
|
||||
},
|
||||
&(),
|
||||
);
|
||||
}
|
||||
|
||||
cursor.next(&());
|
||||
cursor.next();
|
||||
}
|
||||
}
|
||||
}
|
||||
new_entries.append(cursor.suffix(&()), &());
|
||||
new_entries.append(cursor.suffix(), &());
|
||||
drop(cursor);
|
||||
|
||||
self.buffer_snapshot = new_snapshot;
|
||||
|
||||
Reference in New Issue
Block a user