Skip to content

Instantly share code, notes, and snippets.

@kronos
Created March 5, 2010 16:37
Show Gist options
  • Save kronos/322894 to your computer and use it in GitHub Desktop.
Save kronos/322894 to your computer and use it in GitHub Desktop.
// Ruby.primitive :array_hash
Fixnum* array_hash(STATE, Array* other) {
size_t hash = this->size();
for (size_t idx = 0; idx < other->size(); idx++) {
hash = (hash << 1) | (hash < 0 ? 1 : 0);
hash ^= as<Fixnum>(other->get(state, idx)).to_long();
}
return Fixnum::from(this->size());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment