Created attachment 1861 [details]
The function 'match' is frequently used with an 'x' argument of length 1 to test for inclusion in a set. In particular, this pattern is common in the methods package. For cases like this, building a hash is unnecessary and faster/simpler options are available. This patch speeds up 'match' by 30-40% for the case of a scalar 'x'.
A bit of extra complexity is introduced in my current implementation to avoid the repeated calling of the SEXP data pointer macros. It may be better to simplify the code by calling the macros inside the loop as this imposes only a minor time penalty.
Created attachment 1862 [details]
timings and tests in vignette
Thank you. I've changed it slightly to also "lookup" COMPLEX() and RAW()..
In one of my test cases of match(TRUE, <long-logical>)
this improved speed by more than a factor 10... very impressively!
==> In R-devel svn rev >= 69393