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

diff: intersect unchanged ranges by word-range indices, not by byte ranges #4534

Merged
merged 3 commits into from
Sep 30, 2024

Conversation

yuja
Copy link
Collaborator

@yuja yuja commented Sep 25, 2024

Checklist

If applicable:

  • I have updated CHANGELOG.md
  • I have updated the documentation (README.md, docs/, demos/)
  • I have updated the config schema (cli/src/config-schema.json)
  • I have added tests to cover my changes

@yuja yuja force-pushed the push-tzvnstyxvnlt branch from 5b4b7a2 to abd36aa Compare September 27, 2024 10:44
… recursion

It's cheap to create an empty Vec, and I'm going to remove it anyway.
It's silly that we build new Vec for each recursion stack and merge elements
back. I don't see a measurable performance difference in the diff bench, but
this change will help simplify the next patch. If a result vec were created for
each unchanged_ranges() invocation, it would probably make more sense to return
a list of "local" word positions. Then, callers would have to translate the
returned positions to the caller's local positions.
Intersection of unchanged ranges becomes a simple merge-join loop, so I've
removed the existing tests. I also added a fast path for the common 2-way
diffs in which we don't have to build vec![(pos, vec![pos])].

One source of confusion introduced by this change is that WordPosition means
both global and local indices. This is covered by the added tests, but I might
add separate local/global types later.
@yuja yuja force-pushed the push-tzvnstyxvnlt branch from abd36aa to b1b6295 Compare September 28, 2024 00:31
lib/src/diff.rs Show resolved Hide resolved
@yuja yuja merged commit 68176d9 into jj-vcs:main Sep 30, 2024
18 checks passed
@yuja yuja deleted the push-tzvnstyxvnlt branch September 30, 2024 21:31
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