diff --git a/src/prune_symbol.cpp b/src/prune_symbol.cpp index fc54cf05..ef3529a7 100644 --- a/src/prune_symbol.cpp +++ b/src/prune_symbol.cpp @@ -60,22 +60,67 @@ namespace detail { } // http://eel.is/c++draft/lex.operators#nt:operator-or-punctuator - const std::vector punctuators_and_operators = []() { - std::vector vec{ - "{", "}", "[", "]", "(", ")", - "<:", ":>", "<%", "%>", ";", ":", "...", - "?", "::", ".", ".*", "->", "->*", "~", - "!", "+", "-", "*", "/", "%", "^", "&", "|", - "=", "+=", "-=", "*=", "/=", "%=", "^=", "&=", "|=", - "==", "!=", "<", ">", "<=", ">=", "<=>", "&&", "||", - "<<", ">>", "<<=", ">>=", "++", "--", ",", - // "and", "or", "xor", "not", "bitand", "bitor", "compl", - // "and_eq", "or_eq", "xor_eq", "not_eq", - "#", // extension for {lambda()#1} - }; - std::sort(vec.begin(), vec.end(), [](string_view a, string_view b) { return a.size() > b.size(); }); - return vec; - } (); + // These must be ordered by length, longest first. + const string_view punctuators_and_operators[] { + // 3 character operators + "->*", + "...", + "<=>", + "<<=", + ">>=", + // 2 character operators + "<:", + ":>", + "<%", + "%>", + "::", + ".*", + "->", + "+=", + "-=", + "*=", + "/=", + "%=", + "^=", + "&=", + "|=", + "==", + "!=", + "<=", + ">=", + "&&", + "||", + "<<", + ">>", + "++", + "--", + // 1 character operators + "{", + "}", + "[", + "]", + "(", + ")", + ";", + ":", + "?", + ".", + "~", + "!", + "+", + "-", + "*", + "/", + "%", + "^", + "&", + "|", + "=", + "<", + ">", + ",", + "#", // extension for {lambda()#1} + }; const std::array anonymous_namespace_spellings = {"(anonymous namespace)", "`anonymous namespace'"};