[racket] Case study: using the profiler to trace a performance issue in compiler/zo-parse

From: Danny Yoo (dyoo at cs.wpi.edu)
Date: Sat Mar 17 20:39:35 EDT 2012

> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
> (define cpt-table-as-vector (make-vector 256))
> (for ([ent (in-list cpt-table)])
>  (match ent
>    [(list k sym)
>     (vector-set! cpt-table-as-vector k (cons k sym))]
>    [(list k k* sym)
>     (for ([i (in-range k k*)])
>       (vector-set! cpt-table-as-vector i (cons k sym)))]))

... but of course I need to process the list in reverse order so that
earlier entries take priority over ones later in the cpt-table list.
Otherwise, I don't preserve the program's meaning.  Whoops.  :)

Posted on the users mailing list.