Skip to content

Avoid heap allocation in Convert::try_from symbol matching#1330

Merged
harehare merged 2 commits intofeat/convert-operator-supportfrom
copilot/sub-pr-1320
Feb 24, 2026
Merged

Avoid heap allocation in Convert::try_from symbol matching#1330
harehare merged 2 commits intofeat/convert-operator-supportfrom
copilot/sub-pr-1320

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Feb 24, 2026

Convert::try_from was calling symbol.as_str().as_str() to match on an Ident, which allocates a new String on every call even for the happy path.

Change

Replace the allocating pattern with resolve_with, which passes the interned &str directly to the closure without any heap allocation:

// Before
RuntimeValue::Symbol(symbol) => match symbol.as_str().as_str() { ... }

// After
RuntimeValue::Symbol(symbol) => symbol.resolve_with(|s| match s { ... })

🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

Copilot AI changed the title [WIP] WIP address feedback from PR #1320 on conversion operators Avoid heap allocation in Convert::try_from symbol matching Feb 24, 2026
Copilot AI requested a review from harehare February 24, 2026 14:03
@harehare harehare marked this pull request as ready for review February 24, 2026 14:04
@harehare harehare merged commit dee3ea9 into feat/convert-operator-support Feb 24, 2026
@harehare harehare deleted the copilot/sub-pr-1320 branch February 24, 2026 14:04
harehare added a commit that referenced this pull request Feb 24, 2026
This reverts commit dee3ea9, reversing
changes made to ade78fd.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants