cppparser: Allow move semantics for CPPToken

This should make it a bit more efficient to move tokens around
This commit is contained in:
rdb 2024-03-29 15:00:39 +01:00
parent e1870047c6
commit 12a188b116
3 changed files with 2 additions and 27 deletions

View File

@ -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();

View File

@ -46,29 +46,6 @@ CPPToken(int token, const YYLTYPE &loc, const std::string &str, const YYSTYPE &v
_lval.str = str;
}
/**
*
*/
CPPToken::
CPPToken(const CPPToken &copy) :
_token(copy._token),
_lloc(copy._lloc)
{
_lval.str = copy._lval.str;
_lval.u = copy._lval.u;
}
/**
*
*/
void CPPToken::
operator = (const CPPToken &copy) {
_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.

View File

@ -30,8 +30,6 @@ public:
CPPToken(int token, const YYLTYPE &loc,
const std::string &str = std::string(),
const YYSTYPE &lval = YYSTYPE());
CPPToken(const CPPToken &copy);
void operator = (const CPPToken &copy);
static CPPToken eof();
bool is_eof() const;