Skip to content

Instantly share code, notes, and snippets.

@methodmissing
Created August 29, 2009 23:40
Show Gist options
  • Select an option

  • Save methodmissing/177755 to your computer and use it in GitHub Desktop.

Select an option

Save methodmissing/177755 to your computer and use it in GitHub Desktop.
static int
rb_any_hash(a)
VALUE a;
{
VALUE hval;
switch (TYPE(a)) {
case T_FIXNUM:
case T_SYMBOL:
return (int)a;
break;
case T_STRING:
return rb_str_hash(a);
break;
default:
hval = rb_funcall(a, id_hash, 0);
if (!FIXNUM_P(hval)) {
hval = rb_funcall(hval, '%', 1, INT2FIX(536870923));
}
return (int)FIX2LONG(hval);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment