Skip to content

Commit d85a823

Browse files
authored
Merge branch 'main' into memory-pool
2 parents 2349f15 + c4f7e16 commit d85a823

File tree

6 files changed

+195
-97
lines changed

6 files changed

+195
-97
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ serde_json = "1.0.133"
3535
dyn-clone = "1.0.17"
3636
rustc-hash = "2.1.0"
3737
memchr = "2.7.4"
38-
itertools = "0.13"
3938

4039

4140
codspeed-criterion-compat = { version = "2.7.2", default-features = false, optional = true }

benches/bench.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ use benchmark_repetitive_react_components::{
3030
benchmark_repetitive_react_components_source,
3131
};
3232

33+
use crate::bench_complex_replace_source::benchmark_complex_replace_source_size;
34+
3335
const HELLOWORLD_JS: &str = include_str!(concat!(
3436
env!("CARGO_MANIFEST_DIR"),
3537
"/benches/fixtures/transpile-minify/files/helloworld.js"
@@ -164,6 +166,11 @@ fn bench_rspack_sources(criterion: &mut Criterion) {
164166
benchmark_complex_replace_source_source,
165167
);
166168

169+
group.bench_function(
170+
"complex_replace_source_size",
171+
benchmark_complex_replace_source_size,
172+
);
173+
167174
group.bench_function(
168175
"parse_source_map_from_json",
169176
benchmark_parse_source_map_from_json,

benches/bench_complex_replace_source.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36738,3 +36738,11 @@ pub fn benchmark_complex_replace_source_source(b: &mut Bencher) {
3673836738
black_box(source.source());
3673936739
});
3674036740
}
36741+
36742+
pub fn benchmark_complex_replace_source_size(b: &mut Bencher) {
36743+
let source = LARGE_REPLACE_SOURCE.clone();
36744+
36745+
b.iter(|| {
36746+
black_box(source.size());
36747+
});
36748+
}

src/cached_source.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ use crate::{
1919
#[derive(Default)]
2020
struct CachedData {
2121
hash: OnceLock<u64>,
22+
size: OnceLock<usize>,
2223
line_only_map: OnceLock<Option<SourceMap>>,
2324
columns_map: OnceLock<Option<SourceMap>>,
2425
}
@@ -95,7 +96,7 @@ impl Source for CachedSource {
9596
}
9697

9798
fn size(&self) -> usize {
98-
self.inner.size()
99+
*self.cache.size.get_or_init(|| self.inner.size())
99100
}
100101

101102
fn map(&self, options: &MapOptions) -> Option<SourceMap> {

0 commit comments

Comments
 (0)