Skip to content

Commit b988274

Browse files
authored
refactor(core): use boxcar (#8352)
1 parent 9266677 commit b988274

File tree

4 files changed

+13
-17
lines changed

4 files changed

+13
-17
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,7 @@ xtask_glue = { path = "xtask/glue" }
203203
# Crates needed in the workspace
204204
anyhow = "1.0.100"
205205
boa_engine = "0.21.0"
206+
boxcar = "0.2.14"
206207
bpaf = { version = "0.9.20", features = ["derive"] }
207208
camino = "1.2.1"
208209
cfg-if = "1.0.4"

crates/biome_service/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ version = "0.0.0"
1414
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
1515

1616
[dependencies]
17-
append-only-vec = "0.1.8"
1817
biome_analyze = { workspace = true, features = ["serde"] }
1918
biome_configuration = { workspace = true }
2019
biome_console = { workspace = true }
@@ -61,6 +60,7 @@ biome_resolver = { workspace = true }
6160
biome_rowan = { workspace = true, features = ["serde"] }
6261
biome_string_case = { workspace = true }
6362
biome_text_edit = { workspace = true }
63+
boxcar = { workspace = true }
6464
camino = { workspace = true }
6565
crossbeam = { workspace = true }
6666
either = { workspace = true }

crates/biome_service/src/workspace/server.rs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ use crate::scanner::{
1616
WorkspaceScannerBridge,
1717
};
1818
use crate::workspace::document::{AnyEmbeddedSnippet, DocumentServices};
19-
use append_only_vec::AppendOnlyVec;
2019
use biome_analyze::{AnalyzerPluginVec, RuleCategory};
2120
use biome_configuration::bool::Bool;
2221
use biome_configuration::max_size::MaxSize;
@@ -72,7 +71,7 @@ pub struct WorkspaceServer {
7271
documents: HashMap<Utf8PathBuf, Document, FxBuildHasher>,
7372

7473
/// Stores the document sources used across the workspace
75-
file_sources: AppendOnlyVec<DocumentFileSource>,
74+
file_sources: boxcar::Vec<DocumentFileSource>,
7675

7776
/// Stores patterns to search for.
7877
patterns: HashMap<PatternId, GritQuery, FxBuildHasher>,
@@ -132,7 +131,7 @@ impl WorkspaceServer {
132131
module_graph: Default::default(),
133132
plugin_caches: Default::default(),
134133
documents: Default::default(),
135-
file_sources: AppendOnlyVec::default(),
134+
file_sources: boxcar::Vec::default(),
136135
patterns: Default::default(),
137136
node_cache: Default::default(),
138137
scanner: Scanner::new(watcher_tx),
@@ -260,11 +259,7 @@ impl WorkspaceServer {
260259
///
261260
/// File sources can be inserted using `insert_source()`.
262261
fn get_source(&self, index: usize) -> Option<DocumentFileSource> {
263-
if index < self.file_sources.len() {
264-
Some(self.file_sources[index])
265-
} else {
266-
None
267-
}
262+
self.file_sources.get(index).copied()
268263
}
269264

270265
/// Inserts a file source so that it can be retrieved by index later.
@@ -274,7 +269,7 @@ impl WorkspaceServer {
274269
fn insert_source(&self, document_file_source: DocumentFileSource) -> usize {
275270
self.file_sources
276271
.iter()
277-
.position(|file_source| *file_source == document_file_source)
272+
.position(|(_, file_source)| *file_source == document_file_source)
278273
.unwrap_or_else(|| self.file_sources.push(document_file_source))
279274
}
280275

0 commit comments

Comments
 (0)