#1680 JS: obj.hash implementation

jessevdam Tue 25 Oct 2011

I made an small implementation to make the obj.hash function to work in JS

hashCounter = 1;

fan.sys.ObjUtil.hash = function(obj)
{
  if(obj.m_hash === undefined)
  {
    obj.m_hash = hashCounter++;
  }
  return obj.m_hash;
}

andy Wed 26 Oct 2011

Thats more or less the fall-back I considered. As long as you don't have more than 2^53 objects that should probably be fine - can't imagine that being an issue any time soon (or ever).

helium Thu 27 Oct 2011

Start at -2^53 and you get twice as many objects. Everything beyond that is probably too much work to be worth it.

sarnold Thu 27 Oct 2011

Just want to say that I would like to have a BigInt implementation in the sys pod; that would be nice, and there are implementations in JS afaik. (see http://shootout.alioth.debian.org/)

andy Thu 27 Oct 2011

Start at -2^53 and you get twice as many objects.

Yeah I think that should be fine - especially given the finite lifetime of browser pages.

Just want to say that I would like to have a BigInt implementation in the sys pod

Not sure we'll see that in sys - but would pretty straightforward to provide that in your own pod - could see a lot of stuff like that in a math pod.

dsav Thu 27 Oct 2011

Yeah I think that should be fine - especially given the finite lifetime of browser pages.

Why are you guys concerned about this so much?

andy Thu 27 Oct 2011

About hash support? Its pretty core to equality and an efficient Map implementation.

andy Wed 9 Nov 2011

Fixed - see #1464 and 1485

Login or Signup to reply.