On Wed, Mar 17, 2010 at 1:04 PM, Michael Meissner <meiss...@linux.vnet.ibm.com> wrote: > Note, that many hash tables are computed by the modulus operation, which is > often fairly expensive (and on machines without a hardware divide unit, > requiring a function call). I would expect many switch statements would slow > down if you switch to a hash operation that used modolus. >
Hi Michael, I agree that the cost of modulation can be high, but it can be even higher if we use a bunch of "else if". Consider the situation that a program has about 400 cases on a single switch statement. The cost of modulation will be fixed price so that there should be a certain point that the price bis lower than else if statements. If jump table is possible, it can be a choice, but jump table is not always feasible depending on the values on "case". Thank you for the reply. Jay