mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-05-31 12:21:19 -03:00
ast: Box redirections in ArgumentOrRedirection
Redirections are bigger and less common. Reduces ast size of __fish_complete_gpg.fish by ~28 KB.
This commit is contained in:
@@ -634,7 +634,7 @@ fn can_be_parsed(pop: &mut Populator<'_>) -> bool {
|
||||
#[derive(Debug)]
|
||||
pub enum ArgumentOrRedirection {
|
||||
Argument(Argument),
|
||||
Redirection(Redirection),
|
||||
Redirection(Box<Redirection>), // Boxed because it's bigger
|
||||
}
|
||||
|
||||
impl Default for ArgumentOrRedirection {
|
||||
@@ -647,7 +647,7 @@ impl Acceptor for ArgumentOrRedirection {
|
||||
fn accept<'a>(&'a self, visitor: &mut dyn NodeVisitor<'a>) {
|
||||
match self {
|
||||
Self::Argument(child) => visitor.visit(child),
|
||||
Self::Redirection(child) => visitor.visit(child),
|
||||
Self::Redirection(child) => visitor.visit(&**child),
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -2641,7 +2641,7 @@ fn visit_argument_or_redirection(&mut self, node: &mut ArgumentOrRedirection) {
|
||||
if let Some(arg) = self.try_parse::<Argument>() {
|
||||
*node = ArgumentOrRedirection::Argument(arg);
|
||||
} else if let Some(redir) = self.try_parse::<Redirection>() {
|
||||
*node = ArgumentOrRedirection::Redirection(redir);
|
||||
*node = ArgumentOrRedirection::Redirection(Box::new(redir));
|
||||
} else {
|
||||
internal_error!(
|
||||
self,
|
||||
|
||||
Reference in New Issue
Block a user