Skip to content

Commit 5e5cc67

Browse files
committed
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.
1 parent 06f25b7 commit 5e5cc67

File tree

6 files changed

+6
-6
lines changed

6 files changed

+6
-6
lines changed

src/libsyntax/ast.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -607,7 +607,7 @@ pub enum Stmt_ {
607607
/// Expr with trailing semi-colon (may have any type):
608608
StmtSemi(P<Expr>, NodeId),
609609

610-
StmtMac(Mac, MacStmtStyle),
610+
StmtMac(P<Mac>, MacStmtStyle),
611611
}
612612

613613
#[deriving(Clone, Copy, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show)]

src/libsyntax/ext/expand.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -672,7 +672,7 @@ fn expand_stmt(s: Stmt, fld: &mut MacroExpander) -> SmallVector<P<Stmt>> {
672672
StmtMac(mac, style) => (mac, style),
673673
_ => return expand_non_macro_stmt(s, fld)
674674
};
675-
let expanded_stmt = match expand_mac_invoc(mac, s.span,
675+
let expanded_stmt = match expand_mac_invoc(mac.and_then(|m| m), s.span,
676676
|r| r.make_stmt(),
677677
mark_stmt, fld) {
678678
Some(stmt) => stmt,

src/libsyntax/fold.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1461,7 +1461,7 @@ pub fn noop_fold_stmt<T: Folder>(Spanned {node, span}: Stmt, folder: &mut T)
14611461
}))
14621462
}
14631463
StmtMac(mac, semi) => SmallVector::one(P(Spanned {
1464-
node: StmtMac(folder.fold_mac(mac), semi),
1464+
node: StmtMac(mac.map(|m| folder.fold_mac(m)), semi),
14651465
span: span
14661466
}))
14671467
}

src/libsyntax/parse/parser.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3940,7 +3940,7 @@ impl<'a> Parser<'a> {
39403940
expr = Some(
39413941
self.mk_mac_expr(span.lo,
39423942
span.hi,
3943-
m.node));
3943+
m.and_then(|x| x.node)));
39443944
}
39453945
_ => {
39463946
stmts.push(P(Spanned {

src/libsyntax/print/pprust.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1337,7 +1337,7 @@ impl<'a> State<'a> {
13371337
ast::MacStmtWithBraces => token::Brace,
13381338
_ => token::Paren
13391339
};
1340-
try!(self.print_mac(mac, delim));
1340+
try!(self.print_mac(&**mac, delim));
13411341
match style {
13421342
ast::MacStmtWithBraces => {}
13431343
_ => try!(word(&mut self.s, ";")),

src/libsyntax/visit.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -730,7 +730,7 @@ pub fn walk_stmt<'v, V: Visitor<'v>>(visitor: &mut V, statement: &'v Stmt) {
730730
StmtExpr(ref expression, _) | StmtSemi(ref expression, _) => {
731731
visitor.visit_expr(&**expression)
732732
}
733-
StmtMac(ref macro, _) => visitor.visit_mac(macro),
733+
StmtMac(ref macro, _) => visitor.visit_mac(&**macro),
734734
}
735735
}
736736

0 commit comments

Comments
 (0)