Skip to content
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

Eagerly remove useless mappings #72

Open
loewenheim opened this issue Sep 7, 2023 · 0 comments
Open

Eagerly remove useless mappings #72

loewenheim opened this issue Sep 7, 2023 · 0 comments

Comments

@loewenheim
Copy link
Contributor

In a sourcemap, consecutive mappings to the same location are redundant, because a mapping always applies until the end of the line or the start of the next mapping. For example, consider a sourcemap containing the following mappings:

[…]
(17, 23) -> ("foo.bar", 95, 8)
(17, 31) -> ("foo.bar", 95, 8)
(18, 5)  -> ("foo.bar", 95, 8)
[…]

The middle mapping is redundant—it adds no information that isn't already covered by the first mapping. By contrast, the third mapping is relevant because it's on a new line.

Removing these redundant mappings could for example be done in SourceMapBuilder::into_sourcemap and/or as part of Sourcemap::rewrite.

We might want to consider doing this as part of #71.

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

No branches or pull requests

1 participant