3.4 Using optimized constructs

3.4.4 CASE macro optimization

You can improve the run-time performance of a call to the Common Lisp case macro by using only fixnum key values within a certain range. the Compiler can then expand the macro into code that jumps directly to a memory location instead of using anif statement for every case.

The Compiler can optimize an application of the case macro that satisfies the following qualifications:

(highest-key - lowest-key) < (10 * number-of-keys)

For example, the following code can be fully optimized:

(case x (1 'one)
        (2 'two)
        (4 'four)
        (t 'other-num))


The Advanced User's Guide - 9 SEP 1996

Generated with Harlequin WebMaker