Use cheaper predicate to see if an iterator is empty.
This commit is contained in:
parent
b885328662
commit
1239977a90
@ -125,11 +125,11 @@ pub fn dispatch(sq: Sq, c: keyring::Command) -> Result<()> {
|
||||
.retain_subkeys(|c| {
|
||||
! any_key_predicates || key_predicate(c.key())
|
||||
});
|
||||
if (c.userids().count() == 0
|
||||
&& c.user_attributes().count() == 0
|
||||
&& c.keys().subkeys().count() == 0)
|
||||
if (c.userids().next().is_none()
|
||||
&& c.user_attributes().next().is_none()
|
||||
&& c.keys().subkeys().next().is_none())
|
||||
|| ((any_key_predicates
|
||||
&& c.keys().subkeys().count() == 0)
|
||||
&& c.keys().subkeys().next().is_none())
|
||||
&& (any_cert_predicates
|
||||
&& ! cert_predicate(c.primary_key().key())))
|
||||
{
|
||||
|
@ -360,7 +360,7 @@ impl Command {
|
||||
.filter(|cmd| cmd.get_name() != "help")
|
||||
.map(|cmd| Command::from_command(&parent, cmd))
|
||||
.collect();
|
||||
new.leaf = cmd.get_subcommands().count() == 0;
|
||||
new.leaf = cmd.get_subcommands().next().is_none();
|
||||
new
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user