on master help sign in
Slicing micro-optimization
add3be8Blaž Hrastnik
helix-term/src/ui/editor.rs+4
@@ -270,6 +270,10 @@ impl EditorView {
270
270
271 let text_style = theme.get("ui.text");
271 let text_style = theme.get("ui.text");
272
272
273+ // It's slightly more efficient to produce a full RopeSlice from the Rope, then slice that a bunch
274+ // of times than it is to always call Rope::slice/get_slice (it will internally always hit RSEnum::Light).
275+ let text = text.slice(..);
276+
273 'outer: for event in highlights {
277 'outer: for event in highlights {
274 match event {
278 match event {
275 HighlightEvent::HighlightStart(span) => {
279 HighlightEvent::HighlightStart(span) => {