Slicing micro-optimization
commitadd3be85289a701bf075307d2dfef9fd8a50f69f
authorBlaž Hrastnik <blaz@mxxn.io>
dateWed 12 Jan 2022, 22:27 (5 years ago)
parentdf0d58e
helix-term/src/ui/editor.rs+4
@@ -270,6 +270,10 @@ impl EditorView {
270270
271271 let text_style = theme.get("ui.text");
272272
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+
273277 'outer: for event in highlights {
274278 match event {
275279 HighlightEvent::HighlightStart(span) => {