Skip to content

Eagerly remove useless mappings #72

@loewenheim

Description

@loewenheim

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.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions