numerical computation locks up ruby
Posted
by
kolosy
on Stack Overflow
See other posts from Stack Overflow
or by kolosy
Published on 2012-06-19T19:45:49Z
Indexed on
2012/06/19
21:16 UTC
Read the original article
Hit count: 232
ruby
|ruby-on-rails-3
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?
© Stack Overflow or respective owner