Skip to content

Commit

Permalink
Fix RubyString#byteslice on substring.
Browse files Browse the repository at this point in the history
As value.getBegin() already managed by makeShared19(), the method
byteSubstr() need not take it into account.
  • Loading branch information
grddev committed May 20, 2013
1 parent 3cd83a9 commit c7ed4ab
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions src/org/jruby/RubyString.java
Original file line number Diff line number Diff line change
Expand Up @@ -3512,11 +3512,9 @@ public final IRubyObject substr(Ruby runtime, int beg, int len) {
/* str_byte_substr */
private IRubyObject byteSubstr(Ruby runtime, int beg, int len) {
int length = value.length();
int s = value.getBegin();

if (len < 0 || beg > length) return runtime.getNil();

int p;
if (beg < 0) {
beg += length;
if (beg < 0) return runtime.getNil();
Expand All @@ -3525,13 +3523,9 @@ private IRubyObject byteSubstr(Ruby runtime, int beg, int len) {

if (len <= 0) {
len = 0;
p = 0;
}
else {
p = s + beg;
}

return makeShared19(runtime, p, len);
return makeShared19(runtime, beg, len);
}

/* str_byte_aref */
Expand Down

0 comments on commit c7ed4ab

Please sign in to comment.