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: 2bfa81cf7733
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 468b4e3ef0da
Choose a head ref
  • 4 commits
  • 8 files changed
  • 1 contributor

Commits on Jun 28, 2016

  1. Verified

    This commit was signed with the committer’s verified signature.
    makenowjust Hiroya Fujinami
    Copy the full SHA
    3fe3a18 View commit details
  2. Add new mechanism for visiting all Hash elements without alloc.

    This new mechanism passes in state that makes most Visitor
    construction unnecessary: thread context, currently-visiting Hash,
    and a generic state object.
    headius committed Jun 28, 2016
    Copy the full SHA
    7da1d22 View commit details

Commits on Jun 29, 2016

  1. Use new visitor logic everywhere.

    Nearly all of these are now allocated once, like a lambda. A few
    require more state to be passed in than is reasonable for a
    generic visitor, or require state to be calculated during visit
    and retrieved at the end. These cases were at least reduced to
    only allocate a visitor, rather than a visitor and a state-holding
    object.
    headius committed Jun 29, 2016
    Copy the full SHA
    021c19b View commit details
  2. Deprecate old visitAll to prevent mix-ups.

    See MapJavaProxy's RubyHashMap subclass; it previously override
    the old visitAll, which broke Map instances returned from Java
    because that visitAll was not being used. This will help ensure
    no subclasses are overriding the wrong method. I don't expect
    there's many (or maybe any) other cases in the wild.
    headius committed Jun 29, 2016
    Copy the full SHA
    468b4e3 View commit details
20 changes: 7 additions & 13 deletions core/src/main/java/org/jruby/RubyArray.java
Original file line number Diff line number Diff line change
@@ -208,6 +208,10 @@ public static RubyArray newArrayLight(Ruby runtime, IRubyObject obj) {
return new RubyArrayOneObject(runtime, obj);
}

public static RubyArray newArrayLight(Ruby runtime, IRubyObject car, IRubyObject cdr) {
return new RubyArrayTwoObject(runtime, car, cdr);
}

public static RubyArray newArrayLight(Ruby runtime, IRubyObject... objs) {
return new RubyArray(runtime, objs, false);
}
@@ -3180,12 +3184,7 @@ public IRubyObject uniq_bang19(ThreadContext context, Block block) {

realLength = 0;

hash.visitAll(new RubyHash.Visitor() {
@Override
public void visit(IRubyObject key, IRubyObject value) {
append(value);
}
});
hash.visitAll(context, RubyHash.AppendValueVisitor, this);
return this;
}

@@ -3216,13 +3215,8 @@ public IRubyObject uniq19(ThreadContext context, Block block) {
if (!block.isGiven()) return uniq(context);
RubyHash hash = makeHash(context, block);

final RubyArray result = new RubyArray(context.runtime, getMetaClass(), hash.size());
hash.visitAll(new RubyHash.Visitor() {
@Override
public void visit(IRubyObject key, IRubyObject value) {
result.append(value);
}
});
RubyArray result = new RubyArray(context.runtime, getMetaClass(), hash.size());
hash.visitAll(context, RubyHash.AppendValueVisitor, result);
return result;
}

Loading