Skip to content

Avoid allocations for isort module names#11251

Merged
charliermarsh merged 1 commit intomainfrom
charlie/cow
May 2, 2024
Merged

Avoid allocations for isort module names#11251
charliermarsh merged 1 commit intomainfrom
charlie/cow

Conversation

@charliermarsh
Copy link
Copy Markdown
Member

Summary

Random refactor I noticed when investigating the F401 changes. We don't need to allocate in most cases here.

@charliermarsh charliermarsh added the performance Potential performance improvement label May 2, 2024
Comment on lines +722 to +724
let mut module_name = String::with_capacity(
(level as usize) + module.as_ref().map_or(0, |module| module.len()),
);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👀

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it bad

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it need the as_ref 🤔

@charliermarsh charliermarsh force-pushed the charlie/cow branch 2 times, most recently from dd402ec to ee597c6 Compare May 2, 2024 19:03
@charliermarsh charliermarsh enabled auto-merge (squash) May 2, 2024 19:07
@charliermarsh charliermarsh merged commit 9a1f6f6 into main May 2, 2024
@charliermarsh charliermarsh deleted the charlie/cow branch May 2, 2024 19:17
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented May 2, 2024

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

Formatter (stable)

✅ ecosystem check detected no format changes.

Formatter (preview)

✅ ecosystem check detected no format changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

performance Potential performance improvement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants