mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-23 08:13:08 +08:00
ast: Box a large enum variant
IfStatement is 680 bytes, much larger than the other variants (SwitchStatement is next at 232). An enum is as large as its largest variant, so this saves a bunch, especially since DecoratedStatement is much more likely than IfStatement. This will speed up the no-execute benchmark by 1.07x.
This commit is contained in:
parent
e7b94454df
commit
5641ae71b8
|
@ -2001,7 +2001,8 @@ pub enum StatementVariant {
|
|||
None,
|
||||
NotStatement(NotStatement),
|
||||
BlockStatement(BlockStatement),
|
||||
IfStatement(IfStatement),
|
||||
// IfStatement is much larger than the rest, so we box it.
|
||||
IfStatement(Box<IfStatement>),
|
||||
SwitchStatement(SwitchStatement),
|
||||
DecoratedStatement(DecoratedStatement),
|
||||
}
|
||||
|
@ -2081,7 +2082,7 @@ impl StatementVariant {
|
|||
StatementVariant::None => panic!("cannot visit null statement"),
|
||||
StatementVariant::NotStatement(node) => node,
|
||||
StatementVariant::BlockStatement(node) => node,
|
||||
StatementVariant::IfStatement(node) => node,
|
||||
StatementVariant::IfStatement(node) => &**node,
|
||||
StatementVariant::SwitchStatement(node) => node,
|
||||
StatementVariant::DecoratedStatement(node) => node,
|
||||
}
|
||||
|
@ -3612,7 +3613,7 @@ impl<'s> Populator<'s> {
|
|||
}
|
||||
ParseKeyword::kw_if => {
|
||||
let embedded = self.allocate_visit::<IfStatement>();
|
||||
Box::new(StatementVariant::IfStatement(*embedded))
|
||||
Box::new(StatementVariant::IfStatement(embedded))
|
||||
}
|
||||
ParseKeyword::kw_switch => {
|
||||
let embedded = self.allocate_visit::<SwitchStatement>();
|
||||
|
|
Loading…
Reference in New Issue
Block a user