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: 68cbdcada675
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: aeeff9f703b1
Choose a head ref
  • 3 commits
  • 2 files changed
  • 2 contributors

Commits on Jan 16, 2018

  1. String#-@ deduplicates unfrozen strings

    Already-frozen strings remain unchanged for compatibility.
    https://bugs.ruby-lang.org/issues/13077
    #4876.
    ChrisBr committed Jan 16, 2018

    Verified

    This commit was signed with the committer’s verified signature. The key has expired.
    aurelien-reeves Aurélien Reeves
    Copy the full SHA
    8a8fdc0 View commit details
  2. Tests for String#@- deduplicates strings

    c&p from 15ef28a991f66f65bb29751cf2bef3bcb51066fc.
    #4876
    ChrisBr committed Jan 16, 2018

    Verified

    This commit was signed with the committer’s verified signature.
    aurelien-reeves Aurélien Reeves
    Copy the full SHA
    4b0f4c0 View commit details

Commits on Jan 17, 2018

  1. Merge pull request #4983 from ChrisBr/feature/dedup-string-minus

    String#-@ deduplicates unfrozen strings
    kares authored Jan 17, 2018

    Verified

    This commit was signed with the committer’s verified signature.
    aurelien-reeves Aurélien Reeves
    Copy the full SHA
    aeeff9f View commit details
Showing with 4 additions and 2 deletions.
  1. +2 −2 core/src/main/java/org/jruby/RubyString.java
  2. +2 −0 test/mri/ruby/test_string.rb
4 changes: 2 additions & 2 deletions core/src/main/java/org/jruby/RubyString.java
Original file line number Diff line number Diff line change
@@ -1135,8 +1135,8 @@ private IRubyObject op_equalCommon(ThreadContext context, IRubyObject other) {
}

@JRubyMethod(name = "-@") // -'foo' returns frozen string
public final IRubyObject minus_at() {
return isFrozen() ? this : this.dupFrozen();
public final IRubyObject minus_at(ThreadContext context) {
return isFrozen() ? this : context.runtime.freezeAndDedupString(this);
}

@JRubyMethod(name = "+@") // +'foo' returns modifiable string
2 changes: 2 additions & 0 deletions test/mri/ruby/test_string.rb
Original file line number Diff line number Diff line change
@@ -2546,6 +2546,8 @@ def test_uplus_minus

assert_not_equal(str.object_id, (+str).object_id)
assert_equal(str.object_id, (-str).object_id)
bar = %w(b a r).join('')
assert_same(str, -bar, "uminus deduplicates [Feature #13077]")
end

def test_ord