Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: d3d95b41bb69
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 525d713a4b83
Choose a head ref
  • 5 commits
  • 8 files changed
  • 1 contributor

Commits on May 25, 2015

  1. Copy the full SHA
    a8547c0 View commit details
  2. Copy the full SHA
    34664c5 View commit details
  3. Remove implementation and version specific Hash#compare_by_identity s…

    …pecs that are already tested elsewhere.
    chrisseaton committed May 25, 2015
    Copy the full SHA
    e6a3239 View commit details
  4. Copy the full SHA
    cfa6630 View commit details
  5. Copy the full SHA
    525d713 View commit details
51 changes: 0 additions & 51 deletions spec/ruby/core/hash/compare_by_identity_spec.rb
Original file line number Diff line number Diff line change
@@ -11,57 +11,6 @@
@h["a".dup].should be_nil
end

ruby_version_is ''...'2.2' do
it "causes future comparisons on the receiver to be made by identity" do
@h["a"] = :a
@h["a"].should == :a
@h.compare_by_identity
@h["a"].should be_nil
end

it "uses the semantics of BasicObject#equal? to determine key identity" do
-0.0.should_not equal(-0.0) # -0.0 is not flonum
@idh[-0.0] = :a
@idh[-0.0] = :b
[1].should_not equal([1])
@idh[[1]] = :c
@idh[[1]] = :d
:bar.should equal(:bar)
@idh[:bar] = :e
@idh[:bar] = :f
"bar".should_not equal('bar')
@idh["bar"] = :g
@idh["bar"] = :h
@idh.values.should == [:a, :b, :c, :d, :f, :g, :h]
end
end

ruby_version_is '2.2' do
it "causes future comparisons on the receiver to be made by identity" do
@h["a"] = :a
@h["a"].should == :a
@h.compare_by_identity
@h["a"].should == :a
end

it "uses the semantics of BasicObject#equal? to determine key identity" do
-0.0.should_not equal(-0.0) # -0.0 is not flonum
@idh[-0.0] = :a
@idh[-0.0] = :b
[1].should_not equal([1])
@idh[[1]] = :c
@idh[[1]] = :d
:bar.should equal(:bar)
@idh[:bar] = :e
@idh[:bar] = :f
# CRuby r44551 [ruby-core:59640] [Bug #9382]
"bar".should_not equal('bar')
@idh["bar"] = :g
@idh["bar"] = :h
@idh.values.should == [:a, :b, :c, :d, :f, :h]
end
end

it "returns self" do
h = new_hash
h[:foo] = :bar
2 changes: 0 additions & 2 deletions spec/truffle/tags/core/hash/compare_by_identity_tags.txt

This file was deleted.

1 change: 0 additions & 1 deletion spec/truffle/tags/core/hash/element_reference_tags.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
fails:Hash#[] finds a value via an identical key even when its #eql? isn't reflexive
fails:Hash#[] does not compare keys with different #hash values via #eql?
1 change: 0 additions & 1 deletion spec/truffle/tags/core/hash/eql_tags.txt

This file was deleted.

1 change: 0 additions & 1 deletion spec/truffle/tags/core/hash/equal_value_tags.txt

This file was deleted.

1 change: 0 additions & 1 deletion spec/truffle/tags/core/hash/rehash_tags.txt

This file was deleted.

1 change: 1 addition & 0 deletions spec/truffle/tags/core/hash/reject_tags.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
fails:Hash#reject taints the resulting hash
fails:Hash#reject with extra state does not taint the resulting hash
Original file line number Diff line number Diff line change
@@ -389,7 +389,7 @@ public Object setBuckets(VirtualFrame frame, RubyHash hash, Object key, Object v
@Specialization(guards = "isBucketsStorage(hash)")
public Object setBuckets(VirtualFrame frame, RubyHash hash, RubyString key, Object value) {
if (hash.isCompareByIdentity()) {
return setBuckets(frame, hash, key, value);
return setBuckets(frame, hash, (Object) key, value);
} else {
return setBuckets(frame, hash, ruby(frame, "key.frozen? ? key : key.dup.freeze", "key", key), value);
}
@@ -1179,8 +1179,11 @@ public int sizePackedArray(RubyHash hash) {
@ImportStatic(HashGuards.class)
public abstract static class RehashNode extends CoreMethodArrayArgumentsNode {

@Child private HashNode hashNode;

public RehashNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
hashNode = new HashNode(context, sourceSection);
}

@Specialization(guards = "isNullStorage(hash)")
@@ -1189,8 +1192,20 @@ public RubyHash rehashNull(RubyHash hash) {
}

@Specialization(guards = "isPackedArrayStorage(hash)")
public RubyHash rehashPackedArray(RubyHash hash) {
// Nothing to do as we weren't using the hash code anyway
public RubyHash rehashPackedArray(VirtualFrame frame, RubyHash hash) {
assert HashOperations.verifyStore(hash);

final Object[] store = (Object[]) hash.getStore();
final int size = hash.getSize();

for (int n = 0; n < PackedArrayStrategy.MAX_ENTRIES; n++) {
if (n < size) {
PackedArrayStrategy.setHashed(store, n, hashNode.hash(frame, PackedArrayStrategy.getKey(store, n)));
}
}

assert HashOperations.verifyStore(hash);

return hash;
}