On 28.04.2011 16:25, Andrej Mitrovic wrote:

> Here's a little benchmark of searching an array and hash of randomly
> generated strings:

  Make it 16 values and run again :) Sure, the more elements we have, the 
better hash performs.

  But in case of ints/floats, for instance, for small sets especially, the 
difference will be even more significant.

  Chained ifs are better than array search (for fixed and known sets of values, 
of course).

> I guess what I was really looking for is syntax sugar that expands this:
> if (variable in value1, value2, value3, value4)

  Exactly - *that* would be very nice :) I believe this is easily doable using 
templates & mixins, though, not using 'in' operator, but something like 
InSet!(var, values...).

/Alexander

Reply via email to