Browse Source

cppparser: Allow move semantics for CPPToken

This should make it a bit more efficient to move tokens around
rdb 1 year ago
parent
commit
12a188b116

+ 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.
       // Switched to a new file, reset the line number.
       line_number = 0;
       line_number = 0;
     }
     }
-    token = next_token;
+    token = std::move(next_token);
   }
   }
   std::cout << "\n";
   std::cout << "\n";
 
 
@@ -501,7 +501,7 @@ get_next_token0() {
 
 
   CPPToken token(0);
   CPPToken token(0);
   if (!_saved_tokens.empty()) {
   if (!_saved_tokens.empty()) {
-    token = _saved_tokens.back();
+    token = std::move(_saved_tokens.back());
     _saved_tokens.pop_back();
     _saved_tokens.pop_back();
   } else {
   } else {
     token = internal_get_next_token();
     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;
   _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
  * A named constructor for the token returned when the end of file has been
  * reached.
  * reached.

+ 0 - 2
dtool/src/cppparser/cppToken.h

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