Skip to content

perf: Avoid clone in adjust_mappings when possible #125

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from

Conversation

kdy1
Copy link
Contributor

@kdy1 kdy1 commented May 22, 2025

Related: #124 (comment)

Copy link
Member

@Swatinem Swatinem left a comment

Choose a reason for hiding this comment

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

On second thought though. self is being sorted by dst, whereas adjustment is sorted by src.
I’m unsure what the "natural" sort order of these tokens within sourcemaps is? depending on that, this optimization might just not be worth it if it turns out that it always needs to re-sort anyway.

adjustment_tokens.sort_unstable_by_key(key);
Cow::Owned(adjustment_tokens)
};
let adjustment_ranges = create_ranges(&adjustment_tokens, |t| (t.src_line, t.src_col));
Copy link
Member

Choose a reason for hiding this comment

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

the adjustment_tokens are sorted by src, whereas the key fn defined above is sorted by dst, so this is a change in funcionality.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nice catch, thanks!

@kdy1 kdy1 closed this Jun 9, 2025
@kdy1 kdy1 deleted the kdy1/adjust-clone branch June 9, 2025 23:02
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