Avoiding Hash Lookups in a Ruby Implementation