24 May 11:10
Automating widetag dispatch
James M. Lawrence <llmjjmll <at> gmail.com>
2012-05-24 09:10:19 GMT
2012-05-24 09:10:19 GMT
I would like to optimize some (apply #'map-into ..) calls where the
sequence(s) passed are not created by me. That is, optimize the
non-open-coded MAP-INTO.
I gathered the pieces of the widetag dispatching code for
VECTOR-SUBSEQ* and wrote a general macro for creating dispatch tables.
Using the first parameter as the specialized array,
DEFINE-ARRAY-DISPATCH defines each specializing function with a
corresponding type declaration inside. VECTOR-SUBSEQ* may now be
written as:
(define-array-dispatch vector-subseq-dispatch (array start end)
(declare (optimize speed (safety 0)))
(declare (type index start end))
(subseq array start end))
(defun vector-subseq* (sequence start end)
(declare (type vector sequence))
(declare (type index start)
(type (or null index) end)
(optimize speed))
(with-array-data ((data sequence)
(start start)
(end end)
:check-fill-pointer t
:force-inline t)
(vector-subseq-dispatch data start end)))
To slightly complicate matters, the current MAP-INTO is kludgy. With
that kludginess fixed[1], a basic MAP-INTO benchmark drops from 385ms
(Continue reading)
RSS Feed