diff options
author | Jim Meyering <meyering@redhat.com> | 2011-09-15 14:39:44 +0200 |
---|---|---|
committer | Jim Meyering <meyering@redhat.com> | 2011-09-16 12:39:30 +0200 |
commit | aeef1229af5f6ad00d466daa32a6af53c3bf0729 (patch) | |
tree | 90c6d571a6e9f40173b81a21ca1ea8ad6e32e9d6 | |
parent | 2ed5eb19533a372a85f8acd0024ece62922c572e (diff) | |
download | grep-aeef1229af5f6ad00d466daa32a6af53c3bf0729.tar.gz |
maint: dfa: simplify dfaoptimize
* src/dfa.c (dfaoptimize): Simplify.
(dfacomp): Remove now-redundant "if (MBS_SUPPORT)" guard,
since dfaoptimize does nothing if !MBS_SUPPORT.
-rw-r--r-- | src/dfa.c | 40 |
1 files changed, 18 insertions, 22 deletions
@@ -3420,30 +3420,27 @@ dfainit (struct dfa *d) static void dfaoptimize (struct dfa *d) { - if (MBS_SUPPORT) - { - unsigned int i; - if (!using_utf8()) - return; + if (!MBS_SUPPORT || !using_utf8()) + return; - for (i = 0; i < d->tindex; ++i) + unsigned int i; + for (i = 0; i < d->tindex; ++i) + { + switch(d->tokens[i]) { - switch(d->tokens[i]) - { - case ANYCHAR: - /* Lowered. */ - abort (); - case MBCSET: - /* Requires multi-byte algorithm. */ - return; - default: - break; - } + case ANYCHAR: + /* Lowered. */ + abort (); + case MBCSET: + /* Requires multi-byte algorithm. */ + return; + default: + break; } - - free_mbdata (d); - d->mb_cur_max = 1; } + + free_mbdata (d); + d->mb_cur_max = 1; } /* Parse and analyze a single string of the given length. */ @@ -3453,8 +3450,7 @@ 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); + dfaoptimize(d); dfaanalyze(d, searchflag); } |