Skip to content

Commit d94209b

Browse files
committed
perf(linter/new-cap): remove unneeded clone (#12883)
1 parent 6437a3b commit d94209b

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

crates/oxc_linter/src/rules/eslint/new_cap.rs

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,7 @@ impl Rule for NewCap {
476476
|| is_cap_allowed_expression(
477477
short_name,
478478
name,
479-
self.new_is_cap_exceptions.iter(),
479+
self.new_is_cap_exceptions.iter().map(CompactStr::as_str),
480480
self.new_is_cap_exception_pattern.as_ref(),
481481
)
482482
|| (!self.properties && short_name != name);
@@ -498,12 +498,14 @@ impl Rule for NewCap {
498498

499499
let capitalization = &get_cap(short_name);
500500

501-
let caps_allowed = caps_allowed_vec();
502501
let allowed = *capitalization != GetCapResult::Upper
503502
|| is_cap_allowed_expression(
504503
short_name,
505504
name,
506-
self.cap_is_new_exceptions.iter().chain(caps_allowed.iter()),
505+
self.cap_is_new_exceptions
506+
.iter()
507+
.map(CompactStr::as_str)
508+
.chain(CAPS_ALLOWED),
507509
self.cap_is_new_exception_pattern.as_ref(),
508510
)
509511
|| (!self.properties && short_name != name);
@@ -626,14 +628,17 @@ fn extract_name_from_expression(expression: &Expression) -> Option<CompactStr> {
626628
}
627629
}
628630

629-
fn is_cap_allowed_expression<'a>(
631+
fn is_cap_allowed_expression<'a, I>(
630632
short_name: &CompactStr,
631633
name: &CompactStr,
632-
exceptions: impl Iterator<Item = &'a CompactStr>,
634+
exceptions: I,
633635
patterns: Option<&Regex>,
634-
) -> bool {
636+
) -> bool
637+
where
638+
I: Iterator<Item = &'a str>,
639+
{
635640
for exception in exceptions {
636-
if exception == name || exception == short_name {
641+
if exception == name.as_str() || exception == short_name.as_str() {
637642
return true;
638643
}
639644
}

0 commit comments

Comments
 (0)