]> git.lyx.org Git - features.git/blobdiff - src/mathed/MathParser.cpp
* Lazy MathData to avoid unneeded interpretation of macro definitions
[features.git] / src / mathed / MathParser.cpp
index 84069deb2b2841827b01bdb9b0f4b7a3fb5610b9..ebeebd36527ef844efbf18aea9ef986382feaa1b 100644 (file)
@@ -307,7 +307,7 @@ public:
        ///
        Parser(Lexer & lex);
        /// Only use this for reading from .lyx file format, for the reason
-       /// see Parser::tokenize(std::istream &).
+       /// see Parser::tokenize(istream &).
        Parser(istream & is);
        ///
        Parser(docstring const & str);
@@ -896,12 +896,14 @@ void Parser::parse1(InsetMathGrid & grid, unsigned flags,
                        t.cs() == "newcommand" ||
                        t.cs() == "renewcommand")
                {
-                       docstring const type = t.cs();
+                       MacroType type = MacroTypeNewcommand;
+                       if (t.cs() == "def")
+                               type = MacroTypeDef;
                        docstring name;
                        int nargs = 0;
                        int optionals = 0;
-                       std::vector<MathData> optionalValues;
-                       if (t.cs() == "def") {
+                       vector<MathData> optionalValues;
+                       if (type == MacroTypeDef) {
                                // get name
                                name = getToken().cs();
 
@@ -914,7 +916,7 @@ void Parser::parse1(InsetMathGrid & grid, unsigned flags,
                                nargs /= 2;
                                //lyxerr << "read \\def parameter list '" << pars << "'" << endl;
 
-                       } else { // t.cs() == "newcommand" || t.cs() == "renewcommand"
+                       } else {
                                if (getToken().cat() != catBegin) {
                                        error("'{' in \\newcommand expected (1) ");
                                        return;