diff options
Diffstat (limited to 'lexers')
-rw-r--r-- | lexers/LexCPP.cxx | 19 | ||||
-rw-r--r-- | lexers/LexPython.cxx | 8 |
2 files changed, 14 insertions, 13 deletions
diff --git a/lexers/LexCPP.cxx b/lexers/LexCPP.cxx index 0b15a6c29..db8bf5d86 100644 --- a/lexers/LexCPP.cxx +++ b/lexers/LexCPP.cxx @@ -14,6 +14,7 @@ #include <ctype.h> #include <string> +#include <utility> #include <vector> #include <map> #include <algorithm> @@ -101,7 +102,7 @@ std::vector<std::string> StringSplit(const std::string &text, int separator) { std::vector<std::string> vs(text.empty() ? 0 : 1); for (const char ch : text) { if (ch == separator) { - vs.push_back(std::string()); + vs.emplace_back(); } else { vs.back() += ch; } @@ -228,8 +229,8 @@ struct PPDefinition { std::string value; bool isUndef; std::string arguments; - PPDefinition(Sci_Position line_, const std::string &key_, const std::string &value_, bool isUndef_ = false, const std::string &arguments_="") : - line(line_), key(key_), value(value_), isUndef(isUndef_), arguments(arguments_) { + PPDefinition(Sci_Position line_, std::string key_, std::string value_, bool isUndef_ = false, std::string arguments_="") : + line(line_), key(std::move(key_)), value(std::move(value_)), isUndef(isUndef_), arguments(std::move(arguments_)) { } }; @@ -484,7 +485,7 @@ class LexerCPP : public ILexerWithMetaData { struct SymbolValue { std::string value; std::string arguments; - SymbolValue(const std::string &value_="", const std::string &arguments_="") : value(value_), arguments(arguments_) { + SymbolValue(std::string value_="", std::string arguments_="") : value(std::move(value_)), arguments(std::move(arguments_)) { } SymbolValue &operator = (const std::string &value_) { value = value_; @@ -1145,7 +1146,7 @@ void SCI_METHOD LexerCPP::Lex(Sci_PositionU startPos, Sci_Position length, int i } break; case SCE_C_TRIPLEVERBATIM: - if (sc.Match("\"\"\"")) { + if (sc.Match(R"(""")")) { while (sc.Match('"')) { sc.Forward(); } @@ -1176,7 +1177,7 @@ void SCI_METHOD LexerCPP::Lex(Sci_PositionU startPos, Sci_Position length, int i if (sc.Match('@', '\"')) { sc.SetState(SCE_C_VERBATIM|activitySet); sc.Forward(); - } else if (options.triplequotedStrings && sc.Match("\"\"\"")) { + } else if (options.triplequotedStrings && sc.Match(R"(""")")) { sc.SetState(SCE_C_TRIPLEVERBATIM|activitySet); sc.Forward(2); } else if (options.hashquotedStrings && sc.Match('#', '\"')) { @@ -1323,7 +1324,7 @@ void SCI_METHOD LexerCPP::Lex(Sci_PositionU startPos, Sci_Position length, int i if (startValue < restOfLine.length()) value = restOfLine.substr(startValue); preprocessorDefinitions[key] = SymbolValue(value, args); - ppDefineHistory.push_back(PPDefinition(lineCurrent, key, value, false, args)); + ppDefineHistory.emplace_back(lineCurrent, key, value, false, args); definitionsChanged = true; } else { // Value @@ -1334,7 +1335,7 @@ void SCI_METHOD LexerCPP::Lex(Sci_PositionU startPos, Sci_Position length, int i if (OnlySpaceOrTab(value)) value = "1"; // No value defaults to 1 preprocessorDefinitions[key] = value; - ppDefineHistory.push_back(PPDefinition(lineCurrent, key, value)); + ppDefineHistory.emplace_back(lineCurrent, key, value); definitionsChanged = true; } } @@ -1345,7 +1346,7 @@ void SCI_METHOD LexerCPP::Lex(Sci_PositionU startPos, Sci_Position length, int i if (tokens.size() >= 1) { const std::string key = tokens[0]; preprocessorDefinitions.erase(key); - ppDefineHistory.push_back(PPDefinition(lineCurrent, key, "", true)); + ppDefineHistory.emplace_back(lineCurrent, key, "", true); definitionsChanged = true; } } diff --git a/lexers/LexPython.cxx b/lexers/LexPython.cxx index abe1c4be2..df80e499b 100644 --- a/lexers/LexPython.cxx +++ b/lexers/LexPython.cxx @@ -346,7 +346,7 @@ public: DefaultLexer(lexicalClasses, ELEMENTS(lexicalClasses)), subStyles(styleSubable, 0x80, 0x40, 0) { } - virtual ~LexerPython() { + ~LexerPython() override { } void SCI_METHOD Release() override { delete this; @@ -683,7 +683,7 @@ void SCI_METHOD LexerPython::Lex(Sci_PositionU startPos, Sci_Position length, in } else if ((sc.state == SCE_P_TRIPLE) || (sc.state == SCE_P_FTRIPLE)) { if (sc.ch == '\\') { sc.Forward(); - } else if (sc.Match("\'\'\'")) { + } else if (sc.Match(R"(''')")) { sc.Forward(); sc.Forward(); sc.ForwardSetState(SCE_P_DEFAULT); @@ -692,7 +692,7 @@ void SCI_METHOD LexerPython::Lex(Sci_PositionU startPos, Sci_Position length, in } else if ((sc.state == SCE_P_TRIPLEDOUBLE) || (sc.state == SCE_P_FTRIPLEDOUBLE)) { if (sc.ch == '\\') { sc.Forward(); - } else if (sc.Match("\"\"\"")) { + } else if (sc.Match(R"(""")")) { sc.Forward(); sc.Forward(); sc.ForwardSetState(SCE_P_DEFAULT); @@ -723,7 +723,7 @@ void SCI_METHOD LexerPython::Lex(Sci_PositionU startPos, Sci_Position length, in if (sc.ch == quote) { if (IsPySingleQuoteStringState(stack_state)) { matching_stack_i = stack_i; - } else if (quote == '"' ? sc.Match("\"\"\"") : sc.Match("'''")) { + } else if (quote == '"' ? sc.Match(R"(""")") : sc.Match("'''")) { matching_stack_i = stack_i; } } |