aboutsummaryrefslogtreecommitdiff
path: root/helix-term/src/ui
diff options
context:
space:
mode:
authorBlaž Hrastnik2021-12-01 04:08:20 +0000
committerBlaž Hrastnik2021-12-01 04:08:20 +0000
commit259678585c3410044683bf4d2619b2d024a04514 (patch)
tree207a827dded75a761bdca62d1784f1fd3e21676b /helix-term/src/ui
parent7bbf4c5b0675bb794bd88c070472773bd7d7e6bf (diff)
ui: Optimize tree-sitter style lookups
Tree sitter returns an index referring to the position of the scope in the scopes array. We can use that same index to avoid a hashmap lookup and instead store the styles in an array. This currently stores the styles in both a map and an array because the UI still uses hashmap lookups, but it's a reasonable tradeoff.
Diffstat (limited to 'helix-term/src/ui')
-rw-r--r--helix-term/src/ui/editor.rs6
1 files changed, 2 insertions, 4 deletions
diff --git a/helix-term/src/ui/editor.rs b/helix-term/src/ui/editor.rs
index 6299014c..a4fbca99 100644
--- a/helix-term/src/ui/editor.rs
+++ b/helix-term/src/ui/editor.rs
@@ -311,8 +311,7 @@ impl EditorView {
if LineEnding::from_rope_slice(&grapheme).is_some() {
if !out_of_bounds {
let style = spans.iter().fold(text_style, |acc, span| {
- let style = theme.get(theme.scopes()[span.0].as_str());
- acc.patch(style)
+ acc.patch(theme.highlight(span.0))
});
// we still want to render an empty cell with the style
@@ -346,8 +345,7 @@ impl EditorView {
if !out_of_bounds {
let style = spans.iter().fold(text_style, |acc, span| {
- let style = theme.get(theme.scopes()[span.0].as_str());
- acc.patch(style)
+ acc.patch(theme.highlight(span.0))
});
// if we're offscreen just keep going until we hit a new line