[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 3/4] dfa: refactor to prepare for upcoming optimizations
From: |
Jim Meyering |
Subject: |
Re: [PATCH 3/4] dfa: refactor to prepare for upcoming optimizations |
Date: |
Tue, 07 Jun 2011 13:34:13 +0200 |
Paolo Bonzini wrote:
> * src/dfa.c (parse_bracket_exp): Move optimization of MBCSET from here...
> (addtok): ... to here.
> ---
> src/dfa.c | 25 ++++++++++++++++---------
> 1 files changed, 16 insertions(+), 9 deletions(-)
>
> diff --git a/src/dfa.c b/src/dfa.c
> index 6602ae8..8fc6ed0 100644
> --- a/src/dfa.c
> +++ b/src/dfa.c
> @@ -1052,14 +1052,7 @@ parse_bracket_exp (void)
> dfawarn (_("character class syntax is [[:space:]], not [:space:]"));
>
> #if MBS_SUPPORT
> - if (MB_CUR_MAX > 1
> - && (!using_utf8()
> - || invert
> - || work_mbc->nchars != 0
> - || work_mbc->nch_classes != 0
> - || work_mbc->nranges != 0
> - || work_mbc->nequivs != 0
> - || work_mbc->ncoll_elems != 0))
> + if (MB_CUR_MAX > 1)
> {
> static charclass zeroclass;
> work_mbc->invert = invert;
> @@ -1463,7 +1456,21 @@ addtok (token t)
> {
> #if MBS_SUPPORT
> if (MB_CUR_MAX > 1 && t == MBCSET)
> - addtok_mb (MBCSET, ((dfa->nmbcsets - 1) << 2) + 3);
> + {
> + struct mb_char_classes *work_mbc = &dfa->mbcsets[dfa->nmbcsets - 1];
It's slightly tighter and more readable to make this temporary "const".
Only down-side is that inserting "const " pushes line-length to 80 ;-)
ACK either way.
> + /* UTF-8 allows treating a simple, non-inverted MBCSET like a CSET. */
> + if (work_mbc->invert
> + || (!using_utf8() && work_mbc->cset != -1)
> + || work_mbc->nchars != 0
> + || work_mbc->nch_classes != 0
> + || work_mbc->nranges != 0
> + || work_mbc->nequivs != 0
> + || work_mbc->ncoll_elems != 0)
> + addtok_mb (MBCSET, ((dfa->nmbcsets - 1) << 2) + 3);
> + else
> + addtok (CSET + work_mbc->cset);
> + }
> else
> #endif
> addtok_mb (t, 3);