Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix RubyArrayTwoObject#subseq.
Browse files Browse the repository at this point in the history
headius committed Jun 16, 2016
1 parent b2e2611 commit e1c89ce
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions core/src/main/java/org/jruby/specialized/RubyArrayTwoObject.java
Original file line number Diff line number Diff line change
@@ -313,19 +313,19 @@ public IRubyObject store(long index, IRubyObject value) {
public IRubyObject subseq(RubyClass metaClass, long beg, long len, boolean light) {
if (!packed()) return super.subseq(metaClass, beg, len, light);

if (len == 0) return newEmptyArray(metaClass.getClassRuntime());
Ruby runtime = getRuntime();

if (beg < 0 || beg > 1 || len < 1 || len > 2) {
unpack();
return super.subseq(metaClass, beg, len, light);
}
if (beg > 2 || beg < 0 || len < 0) return runtime.getNil();

if (len == 0 || beg == 2) return new RubyArray(runtime, metaClass, IRubyObject.NULL_ARRAY);

if (len == 1) {
if (beg == 0) return new RubyArrayOneObject(metaClass, car);
if (beg == 1) return new RubyArrayOneObject(metaClass, cdr);
if (beg == 0) {
if (len == 1) return new RubyArrayOneObject(metaClass, car);
return new RubyArrayTwoObject(metaClass, this);
}

return new RubyArrayTwoObject(metaClass, this);
// beg == 1, len >= 1
return new RubyArrayOneObject(metaClass, cdr);
}

@Override

0 comments on commit e1c89ce

Please sign in to comment.