Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Made changes to RubyArray hash to not use PerlHash/SipHash #2453

Closed
wants to merge 3 commits into from

Conversation

Who828
Copy link
Contributor

@Who828 Who828 commented Jan 12, 2015

Fixes #2437, this time I have used RubyHash.hashValue with identityHash as salt to replicate what MRI does, hopefully hashValue is similar to MRI's rb_hash function (https://github.com/ruby/ruby/blob/7e8795e3935c9cbf4fe9ed24872a49d31a3a33cf/hash.c#L110).

Let me know if this works.

@kares
Copy link
Member

kares commented Jun 10, 2017

current RubyArray's hashing implementation looks like :

    @JRubyMethod(name = "hash")
    public RubyFixnum hash(ThreadContext context) {
        Ruby runtime = context.runtime;

        long h = Helpers.hashStart(runtime, realLength);

        h = Helpers.murmurCombine(h, System.identityHashCode(RubyArray.class));

        for (int i = 0; i < realLength; i++) {
            IRubyObject value = eltOk(i);
            RubyFixnum n = Helpers.safeHash(context, value);
            h = murmurCombine(h, n.getLongValue());
        }

        h = hashEnd(h);

        return runtime.newFixnum(h);
    }

... so I wonder is this PR still relevant/useful to consider updating?

@headius
Copy link
Member

headius commented Jun 13, 2017

@kares I think you're right.

@headius headius closed this Jun 13, 2017
@headius headius added this to the Invalid or Duplicate milestone Jun 13, 2017
@kares kares mentioned this pull request Jun 22, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Array hashing is in Ruby 1.8 mode
3 participants