[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Emacs-diffs] trunk r117007: Optimize cl-struct-slot-value; fix test
From: |
Daniel Colascione |
Subject: |
Re: [Emacs-diffs] trunk r117007: Optimize cl-struct-slot-value; fix test |
Date: |
Mon, 21 Apr 2014 21:35:33 -0700 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.4.0 |
On 04/21/2014 09:34 PM, Stefan Monnier wrote:
>> - (elt inst (cl-struct-slot-offset struct-type slot-name)))
>> + ;; We could use `elt', but since the byte compiler will resolve the
>> + ;; branch below at compile time, it's more efficient to use the
>> + ;; type-specific accessor.
>> + (if (eq (cl-struct-sequence-type struct-type) 'vector)
>> + (aref inst (cl-struct-slot-offset struct-type slot-name))
>> + (nth (cl-struct-slot-offset struct-type slot-name) inst)))
>
> It won't always resolve the (eq (cl-struct-sequence-type struct-type)
> 'vector) test at compile-time, tho.
It did in my tests, when struct-type was a symbol. When struct-type is
something that might vary, the branch shows up in the bytecode. Maybe
the comment should say "will resolve...when possible".
signature.asc
Description: OpenPGP digital signature