mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 20:42:04 +00:00
Avoid materializing strings
This commit is contained in:
parent
363f466627
commit
7e74af3226
7 changed files with 139 additions and 32 deletions
|
@ -81,7 +81,7 @@ impl File {
|
|||
pub fn incremental_reparse(&self, edit: &AtomEdit) -> Option<File> {
|
||||
let (node, reparser) = find_reparsable_node(self.syntax(), edit.delete)?;
|
||||
let text = replace_range(
|
||||
node.text(),
|
||||
node.text().to_string(),
|
||||
edit.delete - node.range().start(),
|
||||
&edit.insert,
|
||||
);
|
||||
|
@ -97,7 +97,7 @@ impl File {
|
|||
Some(File::new(green_root, errors))
|
||||
}
|
||||
fn full_reparse(&self, edit: &AtomEdit) -> File {
|
||||
let text = replace_range(self.syntax().text(), edit.delete, &edit.insert);
|
||||
let text = replace_range(self.syntax().text().to_string(), edit.delete, &edit.insert);
|
||||
File::parse(&text)
|
||||
}
|
||||
pub fn ast(&self) -> ast::Root {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue