From ad93bc7fda1988e49b4e3a0d85344d7e3dc7df10 Mon Sep 17 00:00:00 2001 From: John Hodge Date: Sat, 21 May 2016 20:10:25 +0800 Subject: Parse - Updates for better memory efficiency (hopefully) --- src/expand/cfg.cpp | 2 +- src/expand/file_line.cpp | 2 +- src/expand/format_args.cpp | 5 ++++- src/expand/macro_rules.cpp | 2 +- 4 files changed, 7 insertions(+), 4 deletions(-) (limited to 'src/expand') diff --git a/src/expand/cfg.cpp b/src/expand/cfg.cpp index 1372d982..345c46ab 100644 --- a/src/expand/cfg.cpp +++ b/src/expand/cfg.cpp @@ -88,7 +88,7 @@ class CCfgExpander: ERROR(sp, E0000, "cfg! doesn't take an identifier"); } - auto lex = TTStreamO(tt); + auto lex = TTStream(tt); auto attrs = Parse_MetaItem(lex); DEBUG("cfg!() - " << attrs); diff --git a/src/expand/file_line.cpp b/src/expand/file_line.cpp index a4117d70..2532613f 100644 --- a/src/expand/file_line.cpp +++ b/src/expand/file_line.cpp @@ -10,7 +10,7 @@ class CExpanderFile: ::std::unique_ptr expand(Span sp, const AST::Crate& crate, const ::std::string& ident, const TokenTree& tt, AST::Module& mod) override { - return box$( TTStreamO(TokenTree(Token(TOK_STRING, sp.filename))) ); + return box$( TTStreamO(TokenTree(Token(TOK_STRING, sp.filename.c_str()))) ); } }; diff --git a/src/expand/format_args.cpp b/src/expand/format_args.cpp index d12096a7..6a3665ec 100644 --- a/src/expand/format_args.cpp +++ b/src/expand/format_args.cpp @@ -45,7 +45,10 @@ class CFormatArgsExpander: } // TODO: Expand format_args! - return box$( TTStreamO(TokenTree(::std::vector{TokenTree(TOK_PAREN_OPEN), TokenTree(TOK_PAREN_CLOSE)})) ); + ::std::vector toks; + toks.push_back( TokenTree(TOK_PAREN_OPEN) ); + toks.push_back( TokenTree(TOK_PAREN_CLOSE) ); + return box$( TTStreamO(TokenTree(mv$(toks))) ); } }; diff --git a/src/expand/macro_rules.cpp b/src/expand/macro_rules.cpp index 562b1468..968bf5f9 100644 --- a/src/expand/macro_rules.cpp +++ b/src/expand/macro_rules.cpp @@ -19,7 +19,7 @@ class CMacroRulesExpander: auto mac = Parse_MacroRules(lex); mod.add_macro( false, ident, mac ); - return box$( TTStreamO(TokenTree()) ); + return ::std::unique_ptr( new TTStreamO(TokenTree()) ); } }; -- cgit v1.2.3