bug-grep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 08/34] maint: dfa: convert #if-MBS_SUPPORT (dfaoptimize, dfac


From: Jim Meyering
Subject: Re: [PATCH 08/34] maint: dfa: convert #if-MBS_SUPPORT (dfaoptimize, dfacomp)
Date: Fri, 16 Sep 2011 10:36:47 +0200

Paul Eggert wrote:
> After that patch, if I'm reading things correctly,
> dfaoptimize's body is of the form
> "if (MBS_SUPPORT) { ... }" and the only call to dfaoptimize
> is of the form "if (MBS_SUPPORT) dfaoptimize(d);".
> One of the "if" tests can be removed.  I'd remove the one
> inside "dfaoptimize" as that results in
> less indenting.

Hi Paul,

Thanks for the review.

Given this new version of dfaoptimize,

    static void
    dfaoptimize (struct dfa *d)
    {
      if (!MBS_SUPPORT || !using_utf8())
        return;

      unsigned int i;
      for (i = 0; i < d->tindex; ++i)
        {
          switch(d->tokens[i])
            {
            case ANYCHAR:
              /* Lowered.  */
              abort ();
            case MBCSET:
              /* Requires multi-byte algorithm.  */
              return;
            default:
              break;
            }
        }

      free_mbdata (d);
      d->mb_cur_max = 1;
    }

    /* Parse and analyze a single string of the given length. */
    void
    dfacomp (char const *s, size_t len, struct dfa *d, int searchflag)
    {
      dfainit(d);
      dfaparse(s, len, d);
      dfamust(d);
      if (MBS_SUPPORT)
        dfaoptimize(d);
      dfaanalyze(d, searchflag);
    }

I've removed the test in dfacomp, since
I prefer to keep the guard nearer the code it's guarding.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]