@@ -988,8 +988,7 @@ protected boolean endWithBytes(Object string, Object suffix, RubyEncoding enc,
988
988
@ Cached BytesNode suffixBytesNode ,
989
989
@ CachedLibrary (limit = "2" ) RubyStringLibrary strings ,
990
990
@ CachedLibrary (limit = "2" ) RubyStringLibrary stringsSuffix ,
991
- @ Cached ConditionProfile leftAdjustProfile ,
992
- @ Cached LoopConditionProfile loopProfile ) {
991
+ @ Cached ConditionProfile isCharacterHeadProfile ) {
993
992
994
993
final Rope stringRope = strings .getRope (string );
995
994
final Rope suffixRope = stringsSuffix .getRope (suffix );
@@ -1007,21 +1006,11 @@ protected boolean endWithBytes(Object string, Object suffix, RubyEncoding enc,
1007
1006
1008
1007
final int offset = stringByteLength - suffixByteLength ;
1009
1008
1010
- if (leftAdjustProfile .profile (!isCharacterHead (enc , stringByteLength , stringBytes , offset ))) {
1009
+ if (isCharacterHeadProfile .profile (!isCharacterHead (enc , stringByteLength , stringBytes , offset ))) {
1011
1010
return false ;
1012
1011
}
1013
1012
1014
- int i = 0 ;
1015
- try {
1016
- for (; loopProfile .inject (i < suffixByteLength ); i ++) {
1017
- if (stringBytes [offset + i ] != suffixBytes [i ]) {
1018
- return false ;
1019
- }
1020
- }
1021
- } finally {
1022
- profileAndReportLoopCount (loopProfile , i );
1023
- }
1024
- return true ;
1013
+ return ArrayUtils .regionEquals (stringBytes , offset , suffixBytes , 0 , suffixByteLength );
1025
1014
}
1026
1015
1027
1016
private boolean isCharacterHead (RubyEncoding enc , int stringByteLength , byte [] stringBytes , int offset ) {
0 commit comments