[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [bug-gperf] nitpick
From: |
Bruno Haible |
Subject: |
Re: [bug-gperf] nitpick |
Date: |
Thu, 12 Aug 2010 00:05:00 +0200 |
User-agent: |
KMail/1.9.9 |
Bruce Korb wrote:
> in_word_set (register const char *str, register unsigned int len)
> {
> if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
> {
> register int key = hash (str, len);
>
> "len" is validated to be at least 19, an yet the hash switch statement
> includes case elements for values 2 through 18 as well.
Yes, indeed the switch statement includes also the cases for
len < MIN_WORD_LENGTH. But this should not cost a measurable loss of
speed, because switch statements are random-accessed.
In other words, the function which computes the hash code is robust,
and the len >= MIN_WORD_LENGTH is just a shortcut to avoid calling
this function.
Bruno