@@ -577,10 +577,11 @@ public Memory valueOfIndex(TraceInfo trace, Memory index) {
577577
578578 String toString = toString ();
579579
580- if (_index < toString .length () && _index >= 0 )
580+ int length = toString .length ();
581+ if (_index < length && _index >= 0 )
581582 return getChar (toString .charAt (_index ));
582- else if (_index < 0 && Math .abs (_index ) <= toString . length () )
583- return getChar (toString .charAt (toString . length () + _index ));
583+ else if (_index < 0 && Math .abs (_index ) <= length )
584+ return getChar (toString .charAt (length + _index ));
584585 else
585586 return CONST_EMPTY_STRING ;
586587 }
@@ -589,10 +590,11 @@ else if (_index < 0 && Math.abs(_index) <= toString.length())
589590 public Memory valueOfIndex (TraceInfo trace , long index ) {
590591 int _index = (int )index ;
591592 String string = toString ();
592- if (_index >= 0 && _index < string .length ())
593+ int length = string .length ();
594+ if (_index >= 0 && _index < length )
593595 return getChar (string .charAt (_index ));
594- else if (_index < 0 && Math .abs (_index ) <= string . length () )
595- return getChar (string .charAt (string . length () + _index ));
596+ else if (_index < 0 && Math .abs (_index ) <= length )
597+ return getChar (string .charAt (length + _index ));
596598 else
597599 return CONST_EMPTY_STRING ;
598600 }
@@ -601,10 +603,11 @@ else if (_index < 0 && Math.abs(_index) <= string.length())
601603 public Memory valueOfIndex (TraceInfo trace , double index ) {
602604 int _index = (int )index ;
603605 String string = toString ();
604- if (_index >= 0 && _index < string .length ())
606+ int length = string .length ();
607+ if (_index >= 0 && _index < length )
605608 return getChar (string .charAt (_index ));
606- else if (_index < 0 && Math .abs (_index ) <= string . length () )
607- return getChar (string .charAt (string . length () + _index ));
609+ else if (_index < 0 && Math .abs (_index ) <= length )
610+ return getChar (string .charAt (length + _index ));
608611 else
609612 return CONST_EMPTY_STRING ;
610613 }
@@ -613,10 +616,11 @@ else if (_index < 0 && Math.abs(_index) <= string.length())
613616 public Memory valueOfIndex (TraceInfo trace , boolean index ) {
614617 int _index = index ? 1 : 0 ;
615618 String string = toString ();
616- if (_index >= 0 && _index < string .length ())
619+ int length = string .length ();
620+ if (_index >= 0 && _index < length )
617621 return getChar (string .charAt (_index ));
618- else if (_index < 0 && Math .abs (_index ) <= string . length () )
619- return getChar (string .charAt (string . length () + _index ));
622+ else if (_index < 0 && Math .abs (_index ) <= length )
623+ return getChar (string .charAt (length + _index ));
620624 else
621625 return CONST_EMPTY_STRING ;
622626 }
@@ -630,10 +634,11 @@ public Memory valueOfIndex(TraceInfo trace, String index) {
630634 _index = tmp .toInteger ();
631635
632636 String string = toString ();
633- if (_index >= 0 && _index < string .length ())
637+ int length = string .length ();
638+ if (_index >= 0 && _index < length )
634639 return getChar (string .charAt (_index ));
635- else if (_index < 0 && Math .abs (_index ) <= string . length () )
636- return getChar (string .charAt (string . length () + _index ));
640+ else if (_index < 0 && Math .abs (_index ) <= length )
641+ return getChar (string .charAt (length + _index ));
637642 else
638643 return CONST_EMPTY_STRING ;
639644 }
0 commit comments