Skip to content

Commit 7c0e0ff

Browse files
committed
try using SmallVec for subdiagnostics
1 parent ea270d1 commit 7c0e0ff

3 files changed

Lines changed: 5 additions & 2 deletions

File tree

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/ruff_db/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ salsa = { workspace = true }
4040
schemars = { workspace = true, optional = true }
4141
serde = { workspace = true, optional = true }
4242
serde_json = { workspace = true, optional = true }
43+
smallvec = { workspace = true }
4344
thiserror = { workspace = true }
4445
tracing = { workspace = true }
4546
tracing-subscriber = { workspace = true, optional = true }

crates/ruff_db/src/diagnostic/mod.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use ruff_source_file::{LineColumn, SourceCode, SourceFile};
55

66
use ruff_annotate_snippets::Level as AnnotateLevel;
77
use ruff_text_size::{Ranged, TextRange, TextSize};
8+
use smallvec::SmallVec;
89

910
pub use self::render::{DisplayDiagnostic, DisplayDiagnostics, FileResolver, Input};
1011
use crate::{Db, files::File};
@@ -61,7 +62,7 @@ impl Diagnostic {
6162
severity,
6263
message: message.into_diagnostic_message(),
6364
annotations: vec![],
64-
subs: vec![],
65+
subs: SmallVec::new(),
6566
fix: None,
6667
parent: None,
6768
noqa_offset: None,
@@ -479,7 +480,7 @@ struct DiagnosticInner {
479480
severity: Severity,
480481
message: DiagnosticMessage,
481482
annotations: Vec<Annotation>,
482-
subs: Vec<SubDiagnostic>,
483+
subs: SmallVec<[SubDiagnostic; 1]>,
483484
fix: Option<Fix>,
484485
parent: Option<TextSize>,
485486
noqa_offset: Option<TextSize>,

0 commit comments

Comments
 (0)