Remove unnecessary Arc<String> indirection in `Document.ime_text` (#1822)

This commit is contained in:
JustForFun88 2022-12-20 00:45:53 +05:00 committed by GitHub
parent 3c82433e7d
commit aed91a570f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 5 deletions

View File

@ -361,7 +361,7 @@ pub struct Document {
pub code_actions: im::HashMap<usize, (PluginId, CodeActionResponse)>,
pub inlay_hints: Option<Spans<InlayHint>>,
pub diagnostics: Option<Arc<Vec<EditorDiagnostic>>>,
ime_text: Option<Arc<String>>,
ime_text: Option<Arc<str>>,
ime_pos: (usize, usize, usize),
pub syntax_selection_range: Option<SyntaxSelectionRanges>,
pub find: Rc<RefCell<Find>>,
@ -980,7 +980,7 @@ pub fn set_ime_pos(&mut self, line: usize, col: usize, shift: usize) {
self.ime_pos = (line, col, shift);
}
pub fn ime_text(&self) -> Option<&Arc<String>> {
pub fn ime_text(&self) -> Option<&Arc<str>> {
self.ime_text.as_ref()
}
@ -988,8 +988,8 @@ pub fn ime_pos(&self) -> (usize, usize, usize) {
self.ime_pos
}
pub fn set_ime_text(&mut self, text: String) {
self.ime_text = Some(Arc::new(text));
pub fn set_ime_text(&mut self, text: &str) {
self.ime_text = Some(Arc::from(text));
self.clear_text_layout_cache();
}

View File

@ -687,7 +687,7 @@ fn event(
editor_data.doc.buffer().offset_to_line_col(offset);
let doc = Arc::make_mut(&mut editor_data.doc);
doc.set_ime_pos(line, col, self.ime.get_shift());
doc.set_ime_text(self.ime.borrow().text().to_string());
doc.set_ime_text(self.ime.borrow().text());
} else {
Arc::make_mut(&mut editor_data.doc).clear_ime_text();
}