internal: Arc<String> -> Arc<str>

This commit is contained in:
Lukas Wirth 2023-04-22 09:48:37 +02:00
parent 63e3bf118d
commit f00dcf9a69
16 changed files with 34 additions and 36 deletions

View file

@ -162,9 +162,9 @@ fn load_crate_graph(
let changes = vfs.take_changes();
for file in changes {
if file.exists() {
let contents = vfs.file_contents(file.file_id).to_vec();
if let Ok(text) = String::from_utf8(contents) {
analysis_change.change_file(file.file_id, Some(Arc::new(text)))
let contents = vfs.file_contents(file.file_id);
if let Ok(text) = std::str::from_utf8(contents) {
analysis_change.change_file(file.file_id, Some(Arc::from(text)))
}
}
}

View file

@ -269,7 +269,7 @@ impl GlobalState {
String::from_utf8(bytes).ok().and_then(|text| {
let (text, line_endings) = LineEndings::normalize(text);
line_endings_map.insert(file.file_id, line_endings);
Some(Arc::new(text))
Some(Arc::from(text))
})
} else {
None

View file

@ -65,7 +65,7 @@ fn integrated_highlighting_benchmark() {
let mut text = host.analysis().file_text(file_id).unwrap().to_string();
text.push_str("\npub fn _dummy() {}\n");
let mut change = Change::new();
change.change_file(file_id, Some(Arc::new(text)));
change.change_file(file_id, Some(Arc::from(text)));
host.apply_change(change);
}
@ -121,7 +121,7 @@ fn integrated_completion_benchmark() {
patch(&mut text, "db.struct_data(self.id)", "sel;\ndb.struct_data(self.id)")
+ "sel".len();
let mut change = Change::new();
change.change_file(file_id, Some(Arc::new(text)));
change.change_file(file_id, Some(Arc::from(text)));
host.apply_change(change);
completion_offset
};
@ -160,7 +160,7 @@ fn integrated_completion_benchmark() {
patch(&mut text, "sel;\ndb.struct_data(self.id)", "self.;\ndb.struct_data(self.id)")
+ "self.".len();
let mut change = Change::new();
change.change_file(file_id, Some(Arc::new(text)));
change.change_file(file_id, Some(Arc::from(text)));
host.apply_change(change);
completion_offset
};