Location: crates/diffguard-lsp/src/text.rs:63
Problem: When change.range is None (full document replacement), the code does *text = change.text.clone(). This clones the entire new text content, but text is being replaced entirely — ownership could be taken directly instead of cloning.
let Some(range) = change.range else {
*text = change.text.clone(); // clones entire document
return Ok(());
};
Why this matters: On large documents, this causes unnecessary heap allocation and copying on every full-document sync (common during file saves, initial opens).
Suggested fix: Use std::mem::take() or std::mem::replace() to take ownership of the incoming text without cloning:
let Some(range) = change.range else {
text.clear();
text.push_str(&change.text);
return Ok(());
};
Or if the API allows: pass change.text by value and let the caller handle ownership transfer.
Context: assigning_clones clippy lint fires here.
Location:
crates/diffguard-lsp/src/text.rs:63Problem: When
change.rangeisNone(full document replacement), the code does*text = change.text.clone(). This clones the entire new text content, buttextis being replaced entirely — ownership could be taken directly instead of cloning.Why this matters: On large documents, this causes unnecessary heap allocation and copying on every full-document sync (common during file saves, initial opens).
Suggested fix: Use
std::mem::take()orstd::mem::replace()to take ownership of the incoming text without cloning:Or if the API allows: pass
change.textby value and let the caller handle ownership transfer.Context:
assigning_clonesclippy lint fires here.