Skip to content

Commit

Permalink
refactor(rust): use cow_to_ascii
Browse files Browse the repository at this point in the history
  • Loading branch information
shulaoda committed Jan 26, 2025
1 parent a501750 commit 881b415
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ impl From<RawCopyPattern> for CopyPattern {
}),
context: context.map(Into::into),
to_type: if let Some(to_type) = to_type {
match to_type.cow_to_lowercase().as_ref() {
match to_type.cow_to_ascii_lowercase().as_ref() {
"dir" => Some(ToType::Dir),
"file" => Some(ToType::File),
"template" => Some(ToType::Template),
Expand Down
4 changes: 2 additions & 2 deletions crates/rspack_binding_values/src/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ impl JsAdditionalTreeRuntimeRequirementsResult {

for item in self.runtime_requirements.value.iter() {
let snake_case = item.to_snake_case();
let name = snake_case.cow_to_uppercase();
let name = snake_case.cow_to_ascii_uppercase();

if let Some(item) = RUNTIME_GLOBAL_MAP.1.get(name.as_ref()) {
runtime_requirements.extend(*item);
Expand Down Expand Up @@ -168,7 +168,7 @@ impl JsRuntimeRequirementInTreeResult {

if let Some(item) = RUNTIME_GLOBAL_MAP
.1
.get(snake_name.cow_to_uppercase().as_ref())
.get(snake_name.cow_to_ascii_uppercase().as_ref())
{
runtime_requirements.extend(*item);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ impl ModuleFilenameHelpers {
.as_str();

if content.len() + 2 == full_match.len() {
match content.cow_to_lowercase().as_ref() {
match content.cow_to_ascii_lowercase().as_ref() {
"identifier" => Cow::from(&ctx.identifier),
"short-identifier" => Cow::from(&ctx.short_identifier),
"resource" => Cow::from(&ctx.resource),
Expand Down
2 changes: 1 addition & 1 deletion crates/rspack_plugin_schemes/src/http_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ fn parse_cache_control(cache_control: &Option<String>, request_time: u64) -> (bo
.filter_map(|part| {
let mut parts = part.splitn(2, '=');
Some((
parts.next()?.trim().cow_to_lowercase(),
parts.next()?.trim().cow_to_ascii_lowercase(),
parts.next().map(|v| v.trim().to_string()),
))
})
Expand Down
2 changes: 1 addition & 1 deletion crates/rspack_plugin_warn_sensitive_module/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ async fn seal(&self, compilation: &mut Compilation) -> Result<()> {
}

let identifier = module.identifier();
let lower_identifier = identifier.cow_to_lowercase();
let lower_identifier = identifier.cow_to_ascii_lowercase();
if let Some(prev_identifier) = not_conflect.remove(lower_identifier.as_ref()) {
conflict.insert(
lower_identifier.into_owned(),
Expand Down
2 changes: 1 addition & 1 deletion crates/rspack_storage/src/fs/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ impl FSError {
return true;
}
let error_content = self.inner.to_string();
let lower_case_error_content = error_content.cow_to_lowercase();
let lower_case_error_content = error_content.cow_to_ascii_lowercase();
lower_case_error_content.contains("no such file")
|| lower_case_error_content.contains("file not exists")
}
Expand Down
4 changes: 2 additions & 2 deletions crates/swc_plugin_import/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ pub fn plugin_import(
.param(0)
.and_then(|v| v.value().as_str())
.unwrap_or("");
out.write(param.cow_to_uppercase().as_ref())?;
out.write(param.cow_to_ascii_uppercase().as_ref())?;
Ok(())
},
),
Expand All @@ -283,7 +283,7 @@ pub fn plugin_import(
.param(0)
.and_then(|v| v.value().as_str())
.unwrap_or("");
out.write(param.cow_to_lowercase().as_ref())?;
out.write(param.cow_to_ascii_lowercase().as_ref())?;
Ok(())
},
),
Expand Down

0 comments on commit 881b415

Please sign in to comment.