Skip to content

Improve performance of safeRecurse #9086

Description

@headius

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions