]> git.tdb.fi Git - libs/core.git/blobdiff - source/regex.cpp
Remove the "optimization" of omitting MATCH_CHAR instruction for characters >LAST_INS...
[libs/core.git] / source / regex.cpp
index d3fd0b7ebc4e58b733947387a6e4f349e83bd7ce..48fe4a7c3422fb027c40481d1f7d39b8fc7010d3 100644 (file)
@@ -244,8 +244,7 @@ Regex::Code Regex::parse_atom(const string &expr, string::const_iterator &i, uns
 
        if(flag)
        {
-               if(static_cast<unsigned char>(*i)<=LAST_INSTRUCTION_)
-                       result+=MATCH_CHAR;
+               result+=MATCH_CHAR;
                result+=*i;
        }
 
@@ -388,11 +387,7 @@ bool Regex::run(const string &str, const string::const_iterator &begin, RegMatch
                        bool negate_match=false;
                        for(; j->citer!=code.end();)
                        {
-                               Instruction instr=static_cast<Instruction>(*j->citer);
-                               if(instr>LAST_INSTRUCTION_)
-                                       instr=MATCH_CHAR;
-                               else
-                                       ++j->citer;
+                               Instruction instr=static_cast<Instruction>(*j->citer++);
 
                                if(instr==NEGATE)
                                        negate_match=true;
@@ -517,11 +512,7 @@ bool Regex::group_compare(const RegMatch::Group &g1, const RegMatch::Group &g2)
 
 string Regex::disassemble_instruction(Code::const_iterator &i) const
 {
-       Instruction instr=static_cast<Instruction>(*i);
-       if(instr>=LAST_INSTRUCTION_)
-               instr=MATCH_CHAR;
-       else
-               ++i;
+       Instruction instr=static_cast<Instruction>(*i++);
 
        ostringstream result;
        switch(instr)
@@ -575,8 +566,7 @@ string Regex::disassemble_instruction(Code::const_iterator &i) const
        case MATCH_ANY:
                result<<"MATCH_ANY";
                break;
-       case FIRST_INSTRUCTION_:
-       case LAST_INSTRUCTION_:
+       default:
                result<<"UNKNOWN "<<instr;
        }