The simpler patch ===================================================== 2002-10-22 Paolo Bonzini (bonzini@gnu.org) * posix/regexec.c (sift_states_bkref): bail out of the innermost loop as soon as possible. --- save/regexec.c Tue Oct 22 22:35:32 2002 +++ ./regexec.c Tue Oct 22 22:36:43 2002 @@ -1927,15 +1927,18 @@ sift_states_bkref (preg, mctx, sctx, str int disabled_idx, subexp_len, to_idx, dst_node; struct re_backref_cache_entry *entry; entry = mctx->bkref_ents + enabled_idx; + if (entry->node != node || entry->str_idx != str_idx) + continue; + subexp_len = entry->subexp_to - entry->subexp_from; to_idx = str_idx + subexp_len; + if (to_idx > sctx->last_str_idx + || sctx->sifted_states[to_idx] == NULL) + continue; + dst_node = (subexp_len ? dfa->nexts[node] : dfa->edests[node].elems[0]); - if (entry->node != node || entry->str_idx != str_idx - || to_idx > sctx->last_str_idx - || sctx->sifted_states[to_idx] == NULL) - continue; if (!STATE_NODE_CONTAINS (sctx->sifted_states[to_idx], dst_node)) continue;