Sunday, July 19, 2009

Postscript to the jump-tables stuff

As some commenters pointed out in my last jump tables post, my recommendation to not really worry about jump tables misses uses cases related to compiler and macro writers. It may be there are cases where hundreds (or even thousands) of cases will appear in a single conditional.

I should have been more clear in what I was trying to say: If you're writing case expressions directly (not generated), then you probably never have to worry about jump tables. That is, if you think you should take your case expression and write a jump table macro for it, you're probably wasting your time. If you are generating case expressions, you may have to consider the possibility when the number of cases is very large since the data indicates hundreds or thousands of cases does make a difference.

Of course, these measurements assumed that the case expression used elements such that a jump table was even reasonably representable (see Duane Rettig's comment). It's a relatively narrow use case, but is likely applicable to most other situations where the number of conditions is hovering around ten.

Thanks to the those who commented. It helps keep these things honest. :) (Comments are the peer review of blogging, after all.) Hopefully I'll get around to looking at some other aspects of this work soon.