@@ -185,7 +185,7 @@ public IRubyObject reset(ThreadContext context) {
185185 @ JRubyMethod (name = "terminate" )
186186 public IRubyObject terminate (ThreadContext context ) {
187187 check (context );
188- curr = str .getByteList (). getRealSize ();
188+ curr = str .size ();
189189 clearMatchStatus ();
190190 return this ;
191191 }
@@ -223,7 +223,7 @@ public IRubyObject set_pos(ThreadContext context, IRubyObject pos) {
223223 Ruby runtime = context .runtime ;
224224
225225 int i = RubyNumeric .num2int (pos );
226- int size = str .getByteList (). getRealSize ();
226+ int size = str .size ();
227227 if (i < 0 ) i += size ;
228228 if (i < 0 || i > size ) throw runtime .newRangeError ("index out of range." );
229229 this .curr = i ;
@@ -242,8 +242,7 @@ public IRubyObject charpos(ThreadContext context) {
242242 }
243243
244244 private IRubyObject extractRange (Ruby runtime , int beg , int end ) {
245- ByteList byteList = str .getByteList ();
246- int size = byteList .getRealSize ();
245+ int size = str .size ();
247246
248247 if (beg > size ) return runtime .getNil ();
249248 if (end > size ) end = size ;
@@ -254,7 +253,7 @@ private IRubyObject extractRange(Ruby runtime, int beg, int end) {
254253 private IRubyObject extractBegLen (Ruby runtime , int beg , int len ) {
255254 assert len >= 0 ;
256255
257- int size = str .getByteList (). getRealSize ();
256+ int size = str .size ();
258257
259258 if (beg > size ) return runtime .getNil ();
260259 len = Math .min (len , size - beg );
@@ -296,7 +295,7 @@ private IRubyObject scan(ThreadContext context, IRubyObject regex, boolean succp
296295 regs = matchRegion ;
297296 }
298297
299- if (ret == -2 ) {
298+ if (ret == -2 ) {
300299 throw runtime .newRaiseException ((RubyClass ) getMetaClass ().getConstant ("ScanError" ), "regexp buffer overflow" );
301300 }
302301 if (ret < 0 ) return context .nil ;
@@ -483,7 +482,7 @@ public IRubyObject getchCommon(ThreadContext context) {
483482 public IRubyObject get_byte (ThreadContext context ) {
484483 check (context );
485484 clearMatchStatus ();
486- if (curr >= str .getByteList (). getRealSize ()) return context .nil ;
485+ if (curr >= str .size ()) return context .nil ;
487486
488487 prev = curr ;
489488 curr ++;
@@ -760,8 +759,7 @@ public IRubyObject rest(ThreadContext context) {
760759 check (context );
761760 Ruby runtime = context .runtime ;
762761
763- ByteList value = str .getByteList ();
764- int realSize = value .getRealSize ();
762+ int realSize = str .size ();
765763
766764 if (curr >= realSize ) {
767765 return RubyString .newEmptyString (runtime , str .getEncoding ());
0 commit comments