Stop using an Arc when setting the file text

This commit is contained in:
Laurențiu Nicola 2024-01-10 12:17:10 +02:00
parent 02b6c181dd
commit 0f43b55e83
11 changed files with 21 additions and 24 deletions

View file

@ -13,7 +13,7 @@ use crate::{CrateGraph, SourceDatabaseExt, SourceDatabaseExt2, SourceRoot, Sourc
#[derive(Default)]
pub struct FileChange {
pub roots: Option<Vec<SourceRoot>>,
pub files_changed: Vec<(FileId, Option<Arc<str>>)>,
pub files_changed: Vec<(FileId, Option<String>)>,
pub crate_graph: Option<CrateGraph>,
}
@ -42,7 +42,7 @@ impl FileChange {
self.roots = Some(roots);
}
pub fn change_file(&mut self, file_id: FileId, new_text: Option<Arc<str>>) {
pub fn change_file(&mut self, file_id: FileId, new_text: Option<String>) {
self.files_changed.push((file_id, new_text))
}
@ -68,7 +68,7 @@ impl FileChange {
let source_root = db.source_root(source_root_id);
let durability = durability(&source_root);
// XXX: can't actually remove the file, just reset the text
let text = text.unwrap_or_else(|| Arc::from(""));
let text = text.as_ref().map(String::as_str).unwrap_or_else(|| "");
db.set_file_text_with_durability(file_id, text, durability)
}
if let Some(crate_graph) = self.crate_graph {