From 409d29c99157adc4efeb5d4ff3c965197b8c3632 Mon Sep 17 00:00:00 2001 From: Pierre-Emmanuel Patry Date: Fri, 23 Jun 2023 11:44:49 +0200 Subject: collector: Remove external container The token collector was using an external container but it was later revealed that this whole reuse thing was not necessary. gcc/rust/ChangeLog: * ast/rust-ast-collector.cc (TokenCollector::TokenCollector): Remove constructor, changing it to an implicit default constructor. * ast/rust-ast-collector.h: Change from container reference to direct container. * ast/rust-ast-dump.h: Change call to constructor. * expand/rust-macro-expand.h (struct MacroExpander): Likewise. Signed-off-by: Pierre-Emmanuel Patry --- gcc/rust/ast/rust-ast-collector.cc | 4 ---- gcc/rust/ast/rust-ast-collector.h | 3 +-- gcc/rust/ast/rust-ast-dump.h | 3 +-- gcc/rust/expand/rust-macro-expand.h | 9 +++------ 4 files changed, 5 insertions(+), 14 deletions(-) (limited to 'gcc') diff --git a/gcc/rust/ast/rust-ast-collector.cc b/gcc/rust/ast/rust-ast-collector.cc index f14cb35..84caeb7 100644 --- a/gcc/rust/ast/rust-ast-collector.cc +++ b/gcc/rust/ast/rust-ast-collector.cc @@ -20,10 +20,6 @@ namespace Rust { namespace AST { -TokenCollector::TokenCollector (std::vector &container) - : tokens (container) -{} - std::vector TokenCollector::collect_tokens () const { diff --git a/gcc/rust/ast/rust-ast-collector.h b/gcc/rust/ast/rust-ast-collector.h index 1b314ac..dc2840b 100644 --- a/gcc/rust/ast/rust-ast-collector.h +++ b/gcc/rust/ast/rust-ast-collector.h @@ -30,7 +30,6 @@ namespace AST { class TokenCollector : public ASTVisitor { public: - TokenCollector (std::vector &container); bool output_trailing_commas = false; void visit (AST::Crate &crate); @@ -39,7 +38,7 @@ public: std::vector collect_tokens () const; private: - std::vector &tokens; + std::vector tokens; /** * Visit all items in given @collection, placing the separator in between but diff --git a/gcc/rust/ast/rust-ast-dump.h b/gcc/rust/ast/rust-ast-dump.h index 78015e5..16c43f3 100644 --- a/gcc/rust/ast/rust-ast-dump.h +++ b/gcc/rust/ast/rust-ast-dump.h @@ -41,8 +41,7 @@ public: template void process (T &v) { - std::vector container; - TokenCollector collector (container); + TokenCollector collector; collector.visit (v); auto tokens = collector.collect_tokens (); diff --git a/gcc/rust/expand/rust-macro-expand.h b/gcc/rust/expand/rust-macro-expand.h index 988a9df..19e71f7 100644 --- a/gcc/rust/expand/rust-macro-expand.h +++ b/gcc/rust/expand/rust-macro-expand.h @@ -396,8 +396,7 @@ struct MacroExpander } } - std::vector tokens; - AST::TokenCollector collector (tokens); + AST::TokenCollector collector; collector.visit (item); @@ -428,8 +427,7 @@ struct MacroExpander } } - std::vector tokens; - AST::TokenCollector collector (tokens); + AST::TokenCollector collector; collector.visit (item); @@ -461,8 +459,7 @@ struct MacroExpander } } - std::vector tokens; - AST::TokenCollector collector (tokens); + AST::TokenCollector collector; collector.visit (item); -- cgit v1.1