Skip to content

Commit b4f29f3

Browse files
committed
jruby: (refactor) review str_new (make enc copy explicit)
1 parent 0cc8638 commit b4f29f3

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

ext/jruby/org/jruby/ext/strscan/RubyStringScanner.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -945,12 +945,9 @@ public IRubyObject values_at(ThreadContext context, IRubyObject index1, IRubyObj
945945

946946
// MRI: str_new
947947
private RubyString newString(Ruby runtime, int start, int length) {
948-
ByteList byteList = str.getByteList();
949-
int begin = byteList.begin();
950-
951-
ByteList newByteList = new ByteList(byteList.unsafeBytes(), begin + start, length, byteList.getEncoding(), true);
952-
953-
return RubyString.newString(runtime, newByteList);
948+
final ByteList strBytes = this.str.getByteList();
949+
ByteList newBytes = new ByteList(strBytes.unsafeBytes(), strBytes.begin() + start, length, true);
950+
return RubyString.newString(runtime, newBytes, strBytes.getEncoding());
954951
}
955952

956953
/**

0 commit comments

Comments
 (0)