[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Revised gperf 2.7.2 patch
From: |
Bruce Lilly |
Subject: |
Revised gperf 2.7.2 patch |
Date: |
Tue, 01 Oct 2002 13:53:15 -0400 |
User-agent: |
Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.2a) Gecko/20020910 |
In February 2002, I posted some patches to gperf 2.7.2 to address
a number of issues:
1. efficient case-independent matching of keywords
2. aoutomatic determination of optimal key positions
A revised patch is available at
http://users.erols.com/blilly/mailparse/gperf.patch
Item #1 above has not changed. Item #2 has been
substantially improved; the method now used is much
faster and handles some pathological cases that were
not handled in the earlier patch.
Additional issues are also handled:
3. more efficient code when all keywords have the same length
4. more efficient code when the -l option is used
5. correct handling of automatic key position determination
when -n option is used
Details:
Vanilla gperf 2.7.2 generates a test like:
if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
Clearly that is inefficient when all keywords have the
same length (MAX_WORD_LENGTH == MIN_WORD_LENGTH). The
patch generates the following in such cases:
if (len == MIN_WORD_LENGTH)
which requires a single comparison rather than two.
When the -l option is used, vanilla gperf checks the
length via lengthtable and a string comparison, then
makes an additional check for a terminating '\0';
that additional check is unnecessary (because of the
lengthtable check).
The revised automatic optimal key position determining
code ensures that at least one key position is used if
the -n option is specified or if all keywords have the
same length.
- Revised gperf 2.7.2 patch,
Bruce Lilly <=