浏览代码

cppparser: Allow move semantics for CPPToken

This should make it a bit more efficient to move tokens around
rdb 1 年之前
父节点
当前提交
12a188b116
共有 3 个文件被更改,包括 2 次插入27 次删除
  1. 2 2
      dtool/src/cppparser/cppPreprocessor.cxx
  2. 0 23
      dtool/src/cppparser/cppToken.cxx
  3. 0 2
      dtool/src/cppparser/cppToken.h

+ 2 - 2
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();

+ 0 - 23
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 &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.

+ 0 - 2
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 &copy);
-  void operator = (const CPPToken &copy);
 
   static CPPToken eof();
   bool is_eof() const;