[racket] case form implemented with a hash

From: Neil Van Dyke (neil at neilvandyke.org)
Date: Thu Sep 29 11:10:03 EDT 2011

> At Thu, 29 Sep 2011 12:25:16 +0200, "Jos Koot" wrote:
>
> > In my case I have a case form which dispatches on a character, 86 
> different
> > ones. Therefore I can dispatch by means of a vector. However, almost 
> every
> > character has its own clause and therefore dispatching on the index 
> of the
> > character would give no speed up.
>

Do I understand correctly that this jump-table-like vector-of-closures 
is not fast enough?

If this were assembler for a conventional architecture, and you were 
doing a DFA-like lexer, I'd think that a jump table would be quite fast 
(but with some bloated constant for code size).

I wonder whether there's an optimization the compiler/JIT can make that 
would be a big help, perhaps with additional hints from the Racket 
code?  And if so, would that optimization likely be useful for anything 
other than optimizing "case" of characters?

-- 
http://www.neilvandyke.org/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20110929/49fdf3dd/attachment.html>

Posted on the users mailing list.