Skip to content

Commit c7475e4

Browse files
committed
perf(highlight): use BTreeMap over IndexMap for highlight configs
1 parent eee4192 commit c7475e4

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

cli/src/highlight.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use std::{
2-
collections::HashSet,
2+
collections::{BTreeMap, HashSet},
33
fmt::Write,
44
fs,
55
io::{self, Write as _},
@@ -12,7 +12,6 @@ use std::{
1212
use ansi_colours::{ansi256_from_rgb, rgb_from_ansi256};
1313
use anstyle::{Ansi256Color, AnsiColor, Color, Effects, RgbColor};
1414
use anyhow::Result;
15-
use indexmap::IndexMap;
1615
use serde::{ser::SerializeMap, Deserialize, Deserializer, Serialize, Serializer};
1716
use serde_json::{json, Value};
1817
use tree_sitter_highlight::{HighlightConfiguration, HighlightEvent, Highlighter, HtmlRenderer};
@@ -83,7 +82,7 @@ impl<'de> Deserialize<'de> for Theme {
8382
{
8483
let mut styles = Vec::new();
8584
let mut highlight_names = Vec::new();
86-
if let Ok(colors) = IndexMap::<String, Value>::deserialize(deserializer) {
85+
if let Ok(colors) = BTreeMap::<String, Value>::deserialize(deserializer) {
8786
highlight_names.reserve(colors.len());
8887
styles.reserve(colors.len());
8988
for (name, style_value) in colors {
@@ -128,7 +127,7 @@ impl Serialize for Theme {
128127
|| effects.contains(Effects::ITALIC)
129128
|| effects.contains(Effects::UNDERLINE)
130129
{
131-
let mut style_json = IndexMap::new();
130+
let mut style_json = BTreeMap::new();
132131
if let Some(color) = color {
133132
style_json.insert("color", color);
134133
}

0 commit comments

Comments
 (0)