Skip to content
Permalink
Browse files

enable optimization for .* except look-behind

  • Loading branch information
k-takata committed Jun 23, 2011
1 parent 6b09450 commit 962464a4dd4a9342febfd3e139d51d4282395b28
Showing with 8 additions and 7 deletions.
  1. +3 −2 regcomp.c
  2. +5 −5 regexec.c
@@ -4885,6 +4885,7 @@ optimize_node_left(Node* node, NodeOptInfo* opt, OptEnv* env)
case ANCHOR_END_BUF:
case ANCHOR_SEMI_END_BUF:
case ANCHOR_END_LINE:
case ANCHOR_LOOK_BEHIND: /* just for (?<=x).* */
add_opt_anc_info(&opt->anc, NANCHOR(node)->type);
break;

@@ -4908,7 +4909,6 @@ optimize_node_left(Node* node, NodeOptInfo* opt, OptEnv* env)
break;

case ANCHOR_PREC_READ_NOT:
case ANCHOR_LOOK_BEHIND: /* Sorry, I can't make use of it. */
case ANCHOR_LOOK_BEHIND_NOT:
break;
}
@@ -5162,7 +5162,8 @@ set_optimize_info_from_tree(Node* node, regex_t* reg, ScanEnv* scan_env)
if (r) return r;

reg->anchor = opt.anc.left_anchor & (ANCHOR_BEGIN_BUF |
ANCHOR_BEGIN_POSITION | ANCHOR_ANYCHAR_STAR | ANCHOR_ANYCHAR_STAR_ML);
ANCHOR_BEGIN_POSITION | ANCHOR_ANYCHAR_STAR | ANCHOR_ANYCHAR_STAR_ML |
ANCHOR_LOOK_BEHIND);

reg->anchor |= opt.anc.right_anchor & (ANCHOR_END_BUF | ANCHOR_SEMI_END_BUF);

@@ -3768,12 +3768,12 @@ onig_search_gpos(regex_t* reg, const UChar* str, const UChar* end,
prev = s;
s += enclen(reg->enc, s);

#if 0
while (!ONIGENC_IS_MBC_NEWLINE(reg->enc, prev, end) && s < range) {
prev = s;
s += enclen(reg->enc, s);
if ((reg->anchor & ANCHOR_LOOK_BEHIND) == 0) {
while (!ONIGENC_IS_MBC_NEWLINE(reg->enc, prev, end) && s < range) {
prev = s;
s += enclen(reg->enc, s);
}
}
#endif
} while (s < range);
goto mismatch;
}

0 comments on commit 962464a

Please sign in to comment.
You can’t perform that action at this time.