unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Re: [Emacs-diffs] feature/byte-switch a75d080: * src/bytecode.c: Refactor to follow GNU coding standards
       [not found] ` <20170211125134.80F4325FCF@vcs0.savannah.gnu.org>
@ 2017-02-11 15:46   ` Stefan Monnier
  2017-02-11 18:13     ` Vibhav Pant
  0 siblings, 1 reply; 2+ messages in thread
From: Stefan Monnier @ 2017-02-11 15:46 UTC (permalink / raw)
  To: emacs-devel; +Cc: Vibhav Pant

> +                    if (BYTE_CODE_SAFE)
> +                      eassert (!NILP (HASH_HASH (h, i)));

Declaring that non-full hashtables are "dangerous" is rather annoying.
In this case, I think we can do better:

                 Lisp_Object hash_code
                   = make_number (h->test.hashfn (&h->test, v1));

this then lets us use EQ (hash_code, ...) instead of hash_code == XUINT
(...)  which not only correctly skips nil hashes but might even be ever
so slightly faster (both use == on the same size of integers, but the
former avoids the cost of XUINT).


        Stefan



^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [Emacs-diffs] feature/byte-switch a75d080: * src/bytecode.c: Refactor to follow GNU coding standards
  2017-02-11 15:46   ` [Emacs-diffs] feature/byte-switch a75d080: * src/bytecode.c: Refactor to follow GNU coding standards Stefan Monnier
@ 2017-02-11 18:13     ` Vibhav Pant
  0 siblings, 0 replies; 2+ messages in thread
From: Vibhav Pant @ 2017-02-11 18:13 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel@gnu.org

On Sat, Feb 11, 2017 at 9:16 PM, Stefan Monnier
<monnier@iro.umontreal.ca> wrote:
>> +                    if (BYTE_CODE_SAFE)
>> +                      eassert (!NILP (HASH_HASH (h, i)));
>
> Declaring that non-full hashtables are "dangerous" is rather annoying.
> In this case, I think we can do better:
>
>                  Lisp_Object hash_code
>                    = make_number (h->test.hashfn (&h->test, v1));
>
> this then lets us use EQ (hash_code, ...) instead of hash_code == XUINT
> (...)  which not only correctly skips nil hashes but might even be ever
> so slightly faster (both use == on the same size of integers, but the
> former avoids the cost of XUINT).

Indeed. Since we only use hash_code when h->test.cmpfn is not NULL,
calculating it only then would also make sense (at the cost of an
extra NULL check).

-- 
Vibhav Pant
vibhavp@gmail.com



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-02-11 18:13 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20170211125132.3738.13650@vcs0.savannah.gnu.org>
     [not found] ` <20170211125134.80F4325FCF@vcs0.savannah.gnu.org>
2017-02-11 15:46   ` [Emacs-diffs] feature/byte-switch a75d080: * src/bytecode.c: Refactor to follow GNU coding standards Stefan Monnier
2017-02-11 18:13     ` Vibhav Pant

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).