Skip to content

Commit 53d488b

Browse files
committed
chore: optimize import
1 parent dcb53ce commit 53d488b

File tree

3 files changed

+17
-19
lines changed

3 files changed

+17
-19
lines changed

crates/rspack_plugin_mf/src/manifest/asset.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
use std::collections::HashSet;
2-
31
use rspack_core::{Compilation, ModuleGraph, ModuleIdentifier};
2+
use rspack_util::fx_hash::FxHashSet as HashSet;
43

54
use super::{
65
data::{AssetsSplit, StatsAssetsGroup},
@@ -12,10 +11,10 @@ pub fn collect_assets_from_chunk(
1211
chunk_key: &rspack_core::ChunkUkey,
1312
entry_point_names: &HashSet<String>,
1413
) -> StatsAssetsGroup {
15-
let mut js_sync = HashSet::<String>::new();
16-
let mut js_async = HashSet::<String>::new();
17-
let mut css_sync = HashSet::<String>::new();
18-
let mut css_async = HashSet::<String>::new();
14+
let mut js_sync = HashSet::<String>::default();
15+
let mut js_async = HashSet::<String>::default();
16+
let mut css_sync = HashSet::<String>::default();
17+
let mut css_async = HashSet::<String>::default();
1918
let chunk = compilation.chunk_by_ukey.expect_get(chunk_key);
2019

2120
for cg in chunk.groups() {
@@ -137,7 +136,7 @@ pub fn collect_usage_files_for_module(
137136
module_identifier: &ModuleIdentifier,
138137
entry_point_names: &HashSet<String>,
139138
) -> Vec<String> {
140-
let mut files = HashSet::new();
139+
let mut files = HashSet::default();
141140
for connection in module_graph.get_incoming_connections(module_identifier) {
142141
let origin_identifier = connection
143142
.original_module_identifier

crates/rspack_plugin_mf/src/manifest/mod.rs

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,7 @@ mod data;
55
mod options;
66
mod utils;
77

8-
use std::{
9-
cell::RefCell,
10-
collections::{HashMap, HashSet},
11-
};
8+
use std::cell::RefCell;
129

1310
use asset::{
1411
collect_assets_for_module, collect_assets_from_chunk, collect_usage_files_for_module,
@@ -31,6 +28,7 @@ use rspack_core::{
3128
};
3229
use rspack_error::Result;
3330
use rspack_hook::{plugin, plugin_hook};
31+
use rspack_util::fx_hash::{FxHashMap as HashMap, FxHashSet as HashSet};
3432
use utils::{
3533
collect_expose_requirements, compose_id_with_separator, ensure_shared_entry, is_hot_file,
3634
parse_consume_shared_identifier, parse_container_exposes_from_identifier,
@@ -228,15 +226,15 @@ async fn process_assets(&self, compilation: &mut Compilation) -> Result<()> {
228226
errors: false,
229227
};
230228
// Gather modules
231-
let exposes_map = RefCell::new(HashMap::<String, StatsExpose>::new());
232-
let shared_map = RefCell::new(HashMap::<String, StatsShared>::new());
229+
let exposes_map = RefCell::new(HashMap::<String, StatsExpose>::default());
230+
let shared_map = RefCell::new(HashMap::<String, StatsShared>::default());
233231
let shared_usage_links = RefCell::new(Vec::<(String, String)>::new());
234-
let provide_module_ids = RefCell::new(HashMap::<String, Vec<ModuleIdentifier>>::new());
235-
let consume_module_ids = RefCell::new(HashMap::<String, Vec<ModuleIdentifier>>::new());
232+
let provide_module_ids = RefCell::new(HashMap::<String, Vec<ModuleIdentifier>>::default());
233+
let consume_module_ids = RefCell::new(HashMap::<String, Vec<ModuleIdentifier>>::default());
236234
let remote_module_ids = RefCell::new(Vec::<ModuleIdentifier>::new());
237235
let container_entry_module = RefCell::new(None::<ModuleIdentifier>);
238-
let module_ids_by_name = RefCell::new(HashMap::<String, ModuleIdentifier>::new());
239-
let self_issued_module_ids = RefCell::new(HashMap::<String, ModuleIdentifier>::new());
236+
let module_ids_by_name = RefCell::new(HashMap::<String, ModuleIdentifier>::default());
237+
let self_issued_module_ids = RefCell::new(HashMap::<String, ModuleIdentifier>::default());
240238
stats.get_modules(&options, |modules| {
241239
for m in modules {
242240
let module_identifier = match m.identifier {
@@ -335,7 +333,7 @@ async fn process_assets(&self, compilation: &mut Compilation) -> Result<()> {
335333
let shared_usage_links = shared_usage_links.into_inner();
336334
collect_expose_requirements(&mut shared_map, &mut exposes_map, shared_usage_links);
337335

338-
let mut aggregated_shared_assets: HashMap<String, StatsAssetsGroup> = HashMap::new();
336+
let mut aggregated_shared_assets: HashMap<String, StatsAssetsGroup> = HashMap::default();
339337
for (pkg, module_ids) in &consume_module_ids {
340338
let entry = aggregated_shared_assets
341339
.entry(pkg.clone())

crates/rspack_plugin_mf/src/manifest/utils.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
use std::{cell::RefCell, collections::HashMap, path::Path};
1+
use std::{cell::RefCell, path::Path};
22

33
use rspack_core::StatsModule;
4+
use rspack_util::fx_hash::FxHashMap as HashMap;
45

56
use super::data::{StatsExpose, StatsShared};
67

0 commit comments

Comments
 (0)