emacs-devel
[Top][All Lists]
Advanced

[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: Stefan Monnier
Subject: Re: [Emacs-diffs] trunk r117007: Optimize cl-struct-slot-value; fix test
Date: Tue, 22 Apr 2014 11:14:45 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4.50 (gnu/linux)

>> 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.

Yes, it does for the case where we could have used the accessor instead
(tho I understand there are cases where using the accessor is impractical).
But I'm not convinced this should be a common case.

> When struct-type is something that might vary, the branch shows up in
> the bytecode.

Not only the branch but the cl-struct-sequence-type call as well.
Ends up much more expansive than an `elt'.

I used `elt' in my original code because my benchmark made me think that
replacing `elt' with `aref' is not worth the extra cost when we can't do
that (the speed difference just for the elt/aref call is less than 10%,
which gets drowned in the noise when you add the typep test; for the
setter, the impact is a bit higher since we end up adding a listp test
which can't be optimized away (contrary to your test), but there again,
the difference is pretty small in practice).

Anyway, either code is fine.  I just wanted to share the results of
my benchmarketting.


        Stefan



reply via email to

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