This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Speed-up character range regexes by up to 2x


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]