numerical computation locks up ruby
- by kolosy
i'm trying to implement an id obfuscation scheme, with a simple hash borrowed elsewhere. i've added a method on the application helper:
@@M_ID = 2**31-1
@@PRIME = 1580030173
@@PRIME_INVERSE = 59260789 # (calculated from MAXID and PRIME offline)
def obfuscate_id(x)
if x
return ((x * @@PRIME) & @@M_ID)
else
x
end
end
for some reason, whenever this is called, ruby locks up, and starts eating up disk space on my mac... like - gigs of it. any ideas?