Skip to content

Commit

Permalink
revset: make evaluate_programmatic() optimize expression
Browse files Browse the repository at this point in the history
It seems generally useful to optimize revset expressions in
`evaluate_programmatic()` so the caller doesn't have to remember to do
it. It should generally be cheap to do so even if it's often not
needed.
  • Loading branch information
martinvonz committed Nov 25, 2023
1 parent 5501642 commit 6d54afa
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/src/git.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ use crate::git_backend::GitBackend;
use crate::op_store::{RefTarget, RefTargetOptionExt, RemoteRef, RemoteRefState};
use crate::refs::BranchPushUpdate;
use crate::repo::{MutableRepo, Repo};
use crate::revset::{self, RevsetExpression};
use crate::revset::RevsetExpression;
use crate::settings::GitSettings;
use crate::store::Store;
use crate::str_util::StringPattern;
Expand Down Expand Up @@ -370,7 +370,7 @@ fn abandon_unreachable_commits(
let abandoned_expression = RevsetExpression::commits(pinned_heads)
.range(&RevsetExpression::commits(hidable_git_heads))
.intersection(&RevsetExpression::visible_heads().ancestors());
let abandoned_commits = revset::optimize(abandoned_expression)
let abandoned_commits = abandoned_expression
.evaluate_programmatic(mut_repo)
.unwrap()
.iter()
Expand Down
2 changes: 1 addition & 1 deletion lib/src/revset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,7 @@ impl RevsetExpression {
self: Rc<Self>,
repo: &'index dyn Repo,
) -> Result<Box<dyn Revset<'index> + 'index>, RevsetEvaluationError> {
self.resolve_programmatic(repo).evaluate(repo)
optimize(self).resolve_programmatic(repo).evaluate(repo)
}
}

Expand Down

0 comments on commit 6d54afa

Please sign in to comment.