Skip to content

Commit 5d06fbb

Browse files
fix: don't allocate new string when not needed
1 parent d975e26 commit 5d06fbb

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

clippy_lints/src/cargo/multiple_crate_versions.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,12 @@ pub(super) fn check(cx: &LateContext<'_>, metadata: &Metadata) {
1616

1717
if let Some(resolve) = &metadata.resolve
1818
&& let Some(local_id) = packages.iter().find_map(|p| {
19-
if p.name.replace('-', "_") == local_name.as_str() {
19+
if p.name
20+
.chars()
21+
.into_iter()
22+
.map(|c| if c == '-' { '_' } else { c })
23+
.eq(local_name.as_str().chars())
24+
{
2025
Some(&p.id)
2126
} else {
2227
None

0 commit comments

Comments
 (0)