Actually, comparing against an array uses less RAM all in all (just the values and the loop, you save the space of all but one cmp and blt ops minus loop ops). On a somewhat caching CPU it should also perform better since the loop needs only be fetched once and then just the array values get read - the slowest is always the memory. Without cache your approach will be faster, saving the loop overhead.
Also depends on the indexing range the CPU is capable of, of course...
You could also combine both methods with a larger loop (did that once on a 6502 to save the few cycles I needed).