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

revset: remove 'index lifetime from InternalRevset #2700

Merged
merged 7 commits into from
Dec 15, 2023

Conversation

yuja
Copy link
Contributor

@yuja yuja commented Dec 14, 2023

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 added 7 commits December 14, 2023 08:51
The idea is that InternalRevset will store a 'static boilerplate function that
borrows an 'index passed by function argument. This way, we can abstract the
index type over Arc<T> and &T without introducing too much generics.
This adds overhead to re-look up IndexEntry, but I don't think that would
have significant impact on performance.
The returned iterator is boxed by caller due to the limitation of the type
system. There's a workaround, but it's super ugly.

https://users.rust-lang.org/t/hrtb-on-multiple-generics/34255/3
Also renamed the boxed version to discriminate it from the cast helper.
Copy link
Member

@martinvonz martinvonz left a comment

Choose a reason for hiding this comment

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

I'm not really against this, but it's not an obvious simplification (many added lines of code, but perhaps easier to reason about?), so I'm curious what the goal is. Will it allow some improvements that would be hard to do with the current design?

@yuja
Copy link
Contributor Author

yuja commented Dec 15, 2023

The goal is to remove unsafe from ReadonlyRepo::change_id_index(). If RevsetImpl holds Arc<ReadonlyIndexSegment> instead of &CompositeIndex, the 'index lifetime can be removed.

main...yuja:jj:push-ntksqqnrwqpy

We can also rewrite RevWalk, etc. to hold Arc, but I don't think abstracting everything makes sense. So the RevsetImpl instead pass &CompositeIndex to InnerRevsets by argument.

@martinvonz
Copy link
Member

The goal is to remove unsafe from ReadonlyRepo::change_id_index().

Oh, that seems nice. Thanks for working on that. I've already reviewed this PR, so I'll go and approve it now.

@yuja yuja merged commit 8fdf9db into jj-vcs:main Dec 15, 2023
15 checks passed
@yuja yuja deleted the push-ynvmvvympkns branch December 15, 2023 05:58
@yuja
Copy link
Contributor Author

yuja commented Dec 15, 2023

And the last bits to remove unsafe. #2706

Thanks for reviewing!

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