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: Jakub Jelinek <jakub at redhat dot com>
- To: Aharon Robbins <arnold at skeeve dot com>
- Cc: bonzini at gnu dot org, libc-alpha at sources dot redhat dot com
- Date: Mon, 12 Jan 2004 13:56:09 +0100
- Subject: Re: [PATCH] Speed-up character range regexes by up to 2x
- References: <200401121500.i0CF0CAe013961@skeeve.com>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
On Mon, Jan 12, 2004 at 05:00:12PM +0200, Aharon Robbins wrote:
> 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.
You are certainly not looking at what is currently in glibc CVS:
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;
int icase = (dfa->mb_cur_max == 1 && (bufp->syntax & RE_ICASE));
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)
{
Jakub