The overlong lookup can also be written without a memory lookup as
0x10000U >> ((0x1531U >> (i*5)) & 31);
On most current x86 chips this has a latency of 3 cycles -- LEA+SHR+SHR -- which is better than an L1 cache hit almost everywhere.