Skip to content

Commit 12a188b

Browse files
committed
cppparser: Allow move semantics for CPPToken
This should make it a bit more efficient to move tokens around
1 parent e187004 commit 12a188b

File tree

3 files changed

+2
-27
lines changed

3 files changed

+2
-27
lines changed

dtool/src/cppparser/cppPreprocessor.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ preprocess_file(const Filename &filename) {
410410
// Switched to a new file, reset the line number.
411411
line_number = 0;
412412
}
413-
token = next_token;
413+
token = std::move(next_token);
414414
}
415415
std::cout << "\n";
416416

@@ -501,7 +501,7 @@ get_next_token0() {
501501

502502
CPPToken token(0);
503503
if (!_saved_tokens.empty()) {
504-
token = _saved_tokens.back();
504+
token = std::move(_saved_tokens.back());
505505
_saved_tokens.pop_back();
506506
} else {
507507
token = internal_get_next_token();

dtool/src/cppparser/cppToken.cxx

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -46,29 +46,6 @@ CPPToken(int token, const YYLTYPE &loc, const std::string &str, const YYSTYPE &v
4646
_lval.str = str;
4747
}
4848

49-
/**
50-
*
51-
*/
52-
CPPToken::
53-
CPPToken(const CPPToken &copy) :
54-
_token(copy._token),
55-
_lloc(copy._lloc)
56-
{
57-
_lval.str = copy._lval.str;
58-
_lval.u = copy._lval.u;
59-
}
60-
61-
/**
62-
*
63-
*/
64-
void CPPToken::
65-
operator = (const CPPToken &copy) {
66-
_token = copy._token;
67-
_lval.str = copy._lval.str;
68-
_lval.u = copy._lval.u;
69-
_lloc = copy._lloc;
70-
}
71-
7249
/**
7350
* A named constructor for the token returned when the end of file has been
7451
* reached.

dtool/src/cppparser/cppToken.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ class CPPToken {
3030
CPPToken(int token, const YYLTYPE &loc,
3131
const std::string &str = std::string(),
3232
const YYSTYPE &lval = YYSTYPE());
33-
CPPToken(const CPPToken &copy);
34-
void operator = (const CPPToken &copy);
3533

3634
static CPPToken eof();
3735
bool is_eof() const;

0 commit comments

Comments
 (0)