From add3be85289a701bf075307d2dfef9fd8a50f69f Mon Sep 17 00:00:00 2001 From: Blaž Hrastnik Date: Wed, 12 Jan 2022 22:27:48 +0900 Subject: Slicing micro-optimization --- helix-term/src/ui/editor.rs | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'helix-term/src/ui') diff --git a/helix-term/src/ui/editor.rs b/helix-term/src/ui/editor.rs index 956db72e..f90fbf74 100644 --- a/helix-term/src/ui/editor.rs +++ b/helix-term/src/ui/editor.rs @@ -270,6 +270,10 @@ impl EditorView { let text_style = theme.get("ui.text"); + // It's slightly more efficient to produce a full RopeSlice from the Rope, then slice that a bunch + // of times than it is to always call Rope::slice/get_slice (it will internally always hit RSEnum::Light). + let text = text.slice(..); + 'outer: for event in highlights { match event { HighlightEvent::HighlightStart(span) => { -- cgit v1.2.3-70-g09d2