Use Rope instead of String for buffer diff base (#11300)
As an attempt to do things better when showing diff hunks, store diff base as Rope, not String, to have cheaper clones when the diff base text is reused, e.g. creating another buffer with the diff base text for hunk diff expanding. Release Notes: - N/A
This commit is contained in:
parent
5f0046b923
commit
b523ee6980
13 changed files with 131 additions and 65 deletions
|
@ -520,8 +520,16 @@ impl Buffer {
|
|||
pub fn new(replica_id: u16, remote_id: BufferId, mut base_text: String) -> Buffer {
|
||||
let line_ending = LineEnding::detect(&base_text);
|
||||
LineEnding::normalize(&mut base_text);
|
||||
Self::new_normalized(replica_id, remote_id, line_ending, Rope::from(base_text))
|
||||
}
|
||||
|
||||
let history = History::new(Rope::from(base_text.as_ref()));
|
||||
pub fn new_normalized(
|
||||
replica_id: u16,
|
||||
remote_id: BufferId,
|
||||
line_ending: LineEnding,
|
||||
normalized: Rope,
|
||||
) -> Buffer {
|
||||
let history = History::new(normalized);
|
||||
let mut fragments = SumTree::new();
|
||||
let mut insertions = SumTree::new();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue