From 12a188b1165bb2b9a9a9fa6aeabe7eb9a574cec3 Mon Sep 17 00:00:00 2001 From: rdb Date: Fri, 29 Mar 2024 15:00:39 +0100 Subject: [PATCH] cppparser: Allow move semantics for CPPToken This should make it a bit more efficient to move tokens around --- dtool/src/cppparser/cppPreprocessor.cxx | 4 ++-- dtool/src/cppparser/cppToken.cxx | 23 ----------------------- dtool/src/cppparser/cppToken.h | 2 -- 3 files changed, 2 insertions(+), 27 deletions(-) diff --git a/dtool/src/cppparser/cppPreprocessor.cxx b/dtool/src/cppparser/cppPreprocessor.cxx index 0aa7e69762..15c6daecaf 100644 --- a/dtool/src/cppparser/cppPreprocessor.cxx +++ b/dtool/src/cppparser/cppPreprocessor.cxx @@ -410,7 +410,7 @@ preprocess_file(const Filename &filename) { // Switched to a new file, reset the line number. line_number = 0; } - token = next_token; + token = std::move(next_token); } std::cout << "\n"; @@ -501,7 +501,7 @@ get_next_token0() { CPPToken token(0); if (!_saved_tokens.empty()) { - token = _saved_tokens.back(); + token = std::move(_saved_tokens.back()); _saved_tokens.pop_back(); } else { token = internal_get_next_token(); diff --git a/dtool/src/cppparser/cppToken.cxx b/dtool/src/cppparser/cppToken.cxx index 88b0d87946..daa624f17f 100644 --- a/dtool/src/cppparser/cppToken.cxx +++ b/dtool/src/cppparser/cppToken.cxx @@ -46,29 +46,6 @@ CPPToken(int token, const YYLTYPE &loc, const std::string &str, const YYSTYPE &v _lval.str = str; } -/** - * - */ -CPPToken:: -CPPToken(const CPPToken ©) : - _token(copy._token), - _lloc(copy._lloc) -{ - _lval.str = copy._lval.str; - _lval.u = copy._lval.u; -} - -/** - * - */ -void CPPToken:: -operator = (const CPPToken ©) { - _token = copy._token; - _lval.str = copy._lval.str; - _lval.u = copy._lval.u; - _lloc = copy._lloc; -} - /** * A named constructor for the token returned when the end of file has been * reached. diff --git a/dtool/src/cppparser/cppToken.h b/dtool/src/cppparser/cppToken.h index 81fc462885..89ced98800 100644 --- a/dtool/src/cppparser/cppToken.h +++ b/dtool/src/cppparser/cppToken.h @@ -30,8 +30,6 @@ public: CPPToken(int token, const YYLTYPE &loc, const std::string &str = std::string(), const YYSTYPE &lval = YYSTYPE()); - CPPToken(const CPPToken ©); - void operator = (const CPPToken ©); static CPPToken eof(); bool is_eof() const;