This is the mail archive of the
libc-alpha@sources.redhat.com
mailing list for the glibc project.
Re: [PATCH] Speed-up character range regexes by up to 2x
- From: Aharon Robbins <arnold at skeeve dot com>
- To: bonzini at gnu dot org
- Cc: libc-alpha at sources dot redhat dot com
- Date: Mon, 12 Jan 2004 17:00:12 +0200
- Subject: Re: [PATCH] Speed-up character range regexes by up to 2x
Paolo,
> >>>>>+#ifdef RE_ENABLE_I18N
> >>>>> int icase = (dfa->mb_cur_max == 1 && (bufp->syntax & RE_ICASE));
> >>>>>+#else
> >>>>>+ int icase = (bufp->syntax & RE_ICASE);
> >>>>>+#endif
> >>>>>
> >>>>>
> >It may be that the correct patch is simply to use:
> >
> > int icase = (dfa->mb_cur_max == 1 && (bufp->syntax & RE_ICASE));
> >
> >with no surrounding #ifdef. If so, fine.
>
> I might be missing something overly obvious, but I see 4 lines added by
> your patch exactly around the line you suggest, not just the #else branch.
>
> Paolo
Look at this code:
| static void
| re_compile_fastmap_iter (bufp, init_state, fastmap)
| regex_t *bufp;
| const re_dfastate_t *init_state;
| char *fastmap;
| {
| re_dfa_t *dfa = (re_dfa_t *) bufp->buffer;
| int node_cnt;
| #ifdef RE_ENABLE_I18N
| int icase = (dfa->mb_cur_max == 1 && (bufp->syntax & RE_ICASE));
| #endif
| for (node_cnt = 0; node_cnt < init_state->nodes.nelem; ++node_cnt)
| {
| int node = init_state->nodes.elems[node_cnt];
| re_token_type_t type = dfa->nodes[node].type;
|
| if (type == CHARACTER)
| {
>>>>> | re_set_fastmap (fastmap, icase, dfa->nodes[node].opr.c);
| #ifdef RE_ENABLE_I18N
| if ((bufp->syntax & RE_ICASE) && dfa->mb_cur_max > 1)
| {
Note how the flagged line (calling re_set_fastmap) uses `icase'. Without
my patch, if RE_ENABLE_I18N is _not_ defined, then `icase' is undeclared.
Boom: compile-time error message.
Thus, either remove the #ifdef/#endif around the original line, or add
in the #else case.
Thanks,
Arnold