News for hackers. Stuff that matters.
Re:Increasing the D Compiler Speed by Over 75% by jongraehl on Thursday July 25, 2013 @02:51PM (#6104224)
I wondered why you don't store the reciprocal w/ the hash table object. Obviously it wastes some space, but it wouldn't be any slower than your specific checks for 4 and 31, I think. (If most of the tables have size 4 or 31, then I'd use your code).
Re:Increasing the D Compiler Speed by Over 75% by WalterBright on Thursday July 25, 2013 @03:03PM (#6104294)
It's not necessary since the set of possible divisors is known in advance.

Also, "multiplying by the reciprocal" is a bit simplistic - there's some other instructions added in based on the specific divisor value. Adding more tests and branches for these likely would not pay off.

Re:Increasing the D Compiler Speed by Over 75% by jongraehl on Thursday July 25, 2013 @04:41PM (#6104838)
Yeah, I looked up the method and agree that if most of your tables are small, it's worth those simple ifs.

I only meant to store it in addition because the alternative, storing an index into the list of divisors (and thus reciprocals) might be slower due to an extra indirection.