Created
March 5, 2010 16:37
-
-
Save kronos/322894 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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