Slash the ast::Stmt type from 104 to 24 bytes.
(on platforms with 64-bit pointers.) The StmtMac variant is rather large and also fairly rare, so let's optimise the common case.
This commit is contained in:
parent
06f25b7e99
commit
5e5cc6749e
@ -607,7 +607,7 @@ pub enum Stmt_ {
|
||||
/// Expr with trailing semi-colon (may have any type):
|
||||
StmtSemi(P<Expr>, NodeId),
|
||||
|
||||
StmtMac(Mac, MacStmtStyle),
|
||||
StmtMac(P<Mac>, MacStmtStyle),
|
||||
}
|
||||
|
||||
#[deriving(Clone, Copy, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show)]
|
||||
|
@ -672,7 +672,7 @@ fn expand_stmt(s: Stmt, fld: &mut MacroExpander) -> SmallVector<P<Stmt>> {
|
||||
StmtMac(mac, style) => (mac, style),
|
||||
_ => return expand_non_macro_stmt(s, fld)
|
||||
};
|
||||
let expanded_stmt = match expand_mac_invoc(mac, s.span,
|
||||
let expanded_stmt = match expand_mac_invoc(mac.and_then(|m| m), s.span,
|
||||
|r| r.make_stmt(),
|
||||
mark_stmt, fld) {
|
||||
Some(stmt) => stmt,
|
||||
|
@ -1461,7 +1461,7 @@ pub fn noop_fold_stmt<T: Folder>(Spanned {node, span}: Stmt, folder: &mut T)
|
||||
}))
|
||||
}
|
||||
StmtMac(mac, semi) => SmallVector::one(P(Spanned {
|
||||
node: StmtMac(folder.fold_mac(mac), semi),
|
||||
node: StmtMac(mac.map(|m| folder.fold_mac(m)), semi),
|
||||
span: span
|
||||
}))
|
||||
}
|
||||
|
@ -3940,7 +3940,7 @@ impl<'a> Parser<'a> {
|
||||
expr = Some(
|
||||
self.mk_mac_expr(span.lo,
|
||||
span.hi,
|
||||
m.node));
|
||||
m.and_then(|x| x.node)));
|
||||
}
|
||||
_ => {
|
||||
stmts.push(P(Spanned {
|
||||
|
@ -1337,7 +1337,7 @@ impl<'a> State<'a> {
|
||||
ast::MacStmtWithBraces => token::Brace,
|
||||
_ => token::Paren
|
||||
};
|
||||
try!(self.print_mac(mac, delim));
|
||||
try!(self.print_mac(&**mac, delim));
|
||||
match style {
|
||||
ast::MacStmtWithBraces => {}
|
||||
_ => try!(word(&mut self.s, ";")),
|
||||
|
@ -730,7 +730,7 @@ pub fn walk_stmt<'v, V: Visitor<'v>>(visitor: &mut V, statement: &'v Stmt) {
|
||||
StmtExpr(ref expression, _) | StmtSemi(ref expression, _) => {
|
||||
visitor.visit_expr(&**expression)
|
||||
}
|
||||
StmtMac(ref macro, _) => visitor.visit_mac(macro),
|
||||
StmtMac(ref macro, _) => visitor.visit_mac(&**macro),
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user