Skip to content

Commit 2a51978

Browse files
committed
fix: arc from str
1 parent 75d5856 commit 2a51978

6 files changed

Lines changed: 15 additions & 10 deletions

File tree

crates/rspack_binding_api/src/raw_options/raw_builtins/raw_context_replacement.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
use std::sync::Arc;
2+
13
use napi::bindgen_prelude::Object;
24
use napi_derive::napi;
35
use rspack_error::{Error, ToStringResultToRspackResultExt};
@@ -36,7 +38,7 @@ impl<'a> TryFrom<RawContextReplacementPluginOptions<'a>> for ContextReplacementP
3638
for key in keys {
3739
let value = raw.get::<String>(&key).to_rspack_result()?;
3840
if let Some(value) = value {
39-
map.insert(key, value);
41+
map.insert(Arc::from(key), value);
4042
}
4143
}
4244
Some(map)

crates/rspack_core/src/context_module_factory.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,7 @@ async fn visit_dirs(
510510
dependencies.push(ContextElementDependency {
511511
id: DependencyId::new(),
512512
request: Arc::from(request),
513-
user_request: Arc::from(r.request),
513+
user_request: r.request.clone(),
514514
category: options.context_options.category,
515515
context: options.resource.clone().into(),
516516
layer: options.layer.clone(),
@@ -529,13 +529,16 @@ async fn visit_dirs(
529529

530530
#[derive(Debug, Clone)]
531531
pub struct AlternativeRequest {
532-
pub context: String,
533-
pub request: String,
532+
pub context: Arc<str>,
533+
pub request: Arc<str>,
534534
}
535535

536536
impl AlternativeRequest {
537-
pub fn new(context: String, request: String) -> Self {
538-
Self { context, request }
537+
pub fn new(context: impl Into<Arc<str>>, request: impl Into<Arc<str>>) -> Self {
538+
Self {
539+
context: context.into(),
540+
request: request.into(),
541+
}
539542
}
540543
}
541544

crates/rspack_plugin_esm_library/src/optimize_chunks.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -601,7 +601,7 @@ pub(crate) fn assign_dyn_import_chunk_short_names(compilation: &mut Compilation)
601601

602602
// Apply assignments
603603
for (chunk_ukey, name) in assignments {
604-
let name_key: Arc<str> = Arc::from(name.into_boxed_str());
604+
let name_key: Arc<str> = Arc::from(name);
605605
let chunk = compilation
606606
.build_chunk_graph_artifact
607607
.chunk_by_ukey

crates/rspack_plugin_extract_css/src/plugin.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -707,7 +707,7 @@ async fn render_manifest(
707707
diagnostics.extend(more_diagnostics);
708708
manifest.push(RenderManifestEntry {
709709
source,
710-
filename: Arc::from(filename.as_ref()),
710+
filename: Arc::from(filename),
711711
has_filename: false,
712712
info: asset_info,
713713
auxiliary: false,

crates/rspack_plugin_html/src/asset.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ impl HtmlPluginAssets {
6262
.entrypoints
6363
.contains_key(name.as_str())
6464
})
65-
.map(|name| Arc::from(name.as_str()))
65+
.map(|name| Arc::from(name.clone()))
6666
.collect()
6767
} else {
6868
compilation

crates/rspack_plugin_split_chunks/src/plugin/chunk.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ fn put_split_chunk_reason(
1616
};
1717
if let Some(chunk_reason) = chunk_reason {
1818
chunk_reason.push(',');
19-
chunk_reason.push_str(&reason);
19+
chunk_reason.push_str(reason);
2020
} else {
2121
*chunk_reason = Some(reason.to_string());
2222
}

0 commit comments

Comments
 (0)