safeRecurse is a method used to safely recurse into collection objects while performing operations like hashing or inspecting. The logic roughly matches CRuby, but has some serious overhead involved due to passing all hash values through IRubyObject even when they can be trivially calculated as a long (e.g. for any fixnum value, we construct an additional fixnum just to get the hash value).
Examine this logic and optimize it for known trivially-hashable types that can't (or shouldn't) have their hash methods overridden, such as all numerics and immediate values. Ideally avoid constructing fixnums for any core type with known hashing logic, only falling back on hash dispatch and fixnums when that logic has been overridden.
safeRecurse is a method used to safely recurse into collection objects while performing operations like hashing or inspecting. The logic roughly matches CRuby, but has some serious overhead involved due to passing all hash values through IRubyObject even when they can be trivially calculated as a long (e.g. for any fixnum value, we construct an additional fixnum just to get the hash value).
Examine this logic and optimize it for known trivially-hashable types that can't (or shouldn't) have their
hashmethods overridden, such as all numerics and immediate values. Ideally avoid constructing fixnums for any core type with known hashing logic, only falling back onhashdispatch and fixnums when that logic has been overridden.