fix: don't allocate new string when not needed

This commit is contained in:
Kristof Mattei 2024-01-14 09:25:31 -07:00
parent d975e267b9
commit 5d06fbb46d
No known key found for this signature in database
GPG Key ID: 89668E582D199AA8

View File

@ -16,7 +16,12 @@ pub(super) fn check(cx: &LateContext<'_>, metadata: &Metadata) {
if let Some(resolve) = &metadata.resolve
&& let Some(local_id) = packages.iter().find_map(|p| {
if p.name.replace('-', "_") == local_name.as_str() {
if p.name
.chars()
.into_iter()
.map(|c| if c == '-' { '_' } else { c })
.eq(local_name.as_str().chars())
{
Some(&p.id)
} else {
None