Skip to content

Commit

Permalink
Showing 2 changed files with 6 additions and 11 deletions.
13 changes: 4 additions & 9 deletions core/src/main/java/org/jruby/RubyRange.java
Original file line number Diff line number Diff line change
@@ -443,13 +443,9 @@ public IRubyObject to_a(ThreadContext context, final Block block) {
final Ruby runtime = context.runtime;

if (begin instanceof RubyFixnum && end instanceof RubyFixnum) {
long lim = ((RubyFixnum) end).getLongValue();
if (!isExclusive) {
lim++;
}

long base = ((RubyFixnum) begin).getLongValue();
long size = lim - base;
long size = ((RubyFixnum) end).getLongValue() - base;
if (!isExclusive) size++;
if (size > Integer.MAX_VALUE) {
throw runtime.newRangeError("Range size too large for to_a");
}
@@ -460,10 +456,9 @@ public IRubyObject to_a(ThreadContext context, final Block block) {
for (int i = 0; i < size; i++) {
array[i] = RubyFixnum.newFixnum(runtime, base + i);
}
return RubyArray.newArrayMayCopy(runtime, array);
} else {
return RubyEnumerable.to_a(context, this);
return RubyArray.newArrayNoCopy(runtime, array);
}
return RubyEnumerable.to_a(context, this);
}

public IRubyObject each(ThreadContext context, final Block block) {
4 changes: 2 additions & 2 deletions core/src/main/java/org/jruby/RubyString.java
Original file line number Diff line number Diff line change
@@ -3265,8 +3265,8 @@ final IRubyObject uptoCommon19(ThreadContext context, IRubyObject arg, boolean e
RubyArray argsArr = RubyArray.newArray(runtime, RubyFixnum.newFixnum(runtime, value.length()), context.nil);

if (b instanceof RubyFixnum && e instanceof RubyFixnum) {
int bi = RubyNumeric.fix2int(b);
int ei = RubyNumeric.fix2int(e);
long bi = RubyNumeric.fix2long(b);
long ei = RubyNumeric.fix2long(e);

while (bi <= ei) {
if (excl && bi == ei) break;

0 comments on commit 9c1abe7

Please sign in to comment.