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:
Kirill Bulatov
2024-05-03 11:18:43 +03:00
committed by GitHub
parent 5f0046b923
commit b523ee6980
13 changed files with 131 additions and 65 deletions
+2 -2
View File
@@ -1065,7 +1065,7 @@ impl LocalWorktree {
&self,
path: &Path,
cx: &mut ModelContext<Worktree>,
) -> Task<Result<(File, String, Option<String>)>> {
) -> Task<Result<(File, String, Option<Rope>)>> {
let path = Arc::from(path);
let abs_path = self.absolutize(&path);
let fs = self.fs.clone();
@@ -1096,7 +1096,7 @@ impl LocalWorktree {
if abs_path_metadata.is_dir || abs_path_metadata.is_symlink {
None
} else {
git_repo.lock().load_index_text(&repo_path)
git_repo.lock().load_index_text(&repo_path).map(Rope::from)
}
}
}));