on master help sign in
Simplify documents & documents_mut()
59ed1c8Blaž Hrastnik
helix-view/src/editor.rs+6−2
@@ -319,20 +319,24 @@ impl Editor {
319 view.ensure_cursor_in_view(doc, self.config.scrolloff)
319 view.ensure_cursor_in_view(doc, self.config.scrolloff)
320 }
320 }
321
321
322+ #[inline]
322 pub fn document(&self, id: DocumentId) -> Option<&Document> {
323 pub fn document(&self, id: DocumentId) -> Option<&Document> {
323 self.documents.get(id)
324 self.documents.get(id)
324 }
325 }
325
326
327+ #[inline]
326 pub fn document_mut(&mut self, id: DocumentId) -> Option<&mut Document> {
328 pub fn document_mut(&mut self, id: DocumentId) -> Option<&mut Document> {
327 self.documents.get_mut(id)
329 self.documents.get_mut(id)
328 }
330 }
329
331
332+ #[inline]
330 pub fn documents(&self) -> impl Iterator<Item = &Document> {
333 pub fn documents(&self) -> impl Iterator<Item = &Document> {
331− self.documents.iter().map(|(_id, doc)| doc)
334+ self.documents.values()
332 }
335 }
333
336
337+ #[inline]
334 pub fn documents_mut(&mut self) -> impl Iterator<Item = &mut Document> {
338 pub fn documents_mut(&mut self) -> impl Iterator<Item = &mut Document> {
335− self.documents.iter_mut().map(|(_id, doc)| doc)
339+ self.documents.values_mut()
336 }
340 }
337
341
338 pub fn document_by_path<P: AsRef<Path>>(&self, path: P) -> Option<&Document> {
342 pub fn document_by_path<P: AsRef<Path>>(&self, path: P) -> Option<&Document> {