emacs-devel
[Top][All Lists]
Advanced

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

Re: [PATCH]: Add new bytecode op `switch' for implementing branch tables


From: Stefan Monnier
Subject: Re: [PATCH]: Add new bytecode op `switch' for implementing branch tables.
Date: Thu, 09 Feb 2017 08:21:21 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux)

>> +  if (HASH_TABLE_SIZE (h) <= 5 && h->test.cmpfn) {

Why not use the linear search when h->test.cmpfn is NULL
(i.e. for `eq` hash tables)?

>> +    /*Try doing a linear search first */

Nitpick: this should be 

        /* Try doing a linear search first.  */

Notice the space at the beginning and the double space after the end
of sentence.

>> +    ptrdiff_t i;
>> +    for (i = 0; i < HASH_TABLE_SIZE (h); i++)
>> +      {
>> +        if (h->test.cmpfn (&h->test, key, HASH_KEY (h, i)))
>> +          return i;
>> +      }
>> +    return -1;
>> +  }

I think we should check hash_code before calling cmpfn.

> Looks like this is the incorrect way to linear-search a hash table, as
> it's sometimes resulting in duplicate hash table entries.

Maybe because it fails to set *hash ?


        Stefan



reply via email to

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