@@ -542,16 +542,14 @@ private CastToIndexNode getEndNode() {
542
542
}
543
543
544
544
private SliceInfo computeSlice (int length , long start , long end ) {
545
- int step = start < end ? 1 : -1 ;
546
- PSlice tmpSlice = factory ().createSlice (getStartNode ().execute (start ), getEndNode ().execute (end ), step );
545
+ PSlice tmpSlice = factory ().createSlice (getStartNode ().execute (start ), getEndNode ().execute (end ), 1 );
547
546
return tmpSlice .computeIndices (length );
548
547
}
549
548
550
549
private SliceInfo computeSlice (int length , Object startO , Object endO ) {
551
550
int start = startO == PNone .NO_VALUE || startO == PNone .NONE ? 0 : getStartNode ().execute (startO );
552
551
int end = endO == PNone .NO_VALUE || endO == PNone .NONE ? length : getEndNode ().execute (endO );
553
- int step = start < end ? 1 : -1 ;
554
- PSlice tmpSlice = factory ().createSlice (start , end , step );
552
+ PSlice tmpSlice = factory ().createSlice (start , end , 1 );
555
553
return tmpSlice .computeIndices (length );
556
554
}
557
555
@@ -564,24 +562,36 @@ Object find(String self, String str, @SuppressWarnings("unused") PNone start, @S
564
562
Object find (String self , String str , long start , @ SuppressWarnings ("unused" ) PNone end ) {
565
563
int len = self .length ();
566
564
SliceInfo info = computeSlice (len , start , len );
565
+ if (info .length == 0 ) {
566
+ return -1 ;
567
+ }
567
568
return findWithBounds (self , str , info .start , info .stop );
568
569
}
569
570
570
571
@ Specialization
571
572
Object find (String self , String str , @ SuppressWarnings ("unused" ) PNone start , long end ) {
572
573
SliceInfo info = computeSlice (self .length (), 0 , end );
574
+ if (info .length == 0 ) {
575
+ return -1 ;
576
+ }
573
577
return findWithBounds (self , str , info .start , info .stop );
574
578
}
575
579
576
580
@ Specialization
577
581
Object find (String self , String str , long start , long end ) {
578
582
SliceInfo info = computeSlice (self .length (), start , end );
583
+ if (info .length == 0 ) {
584
+ return -1 ;
585
+ }
579
586
return findWithBounds (self , str , info .start , info .stop );
580
587
}
581
588
582
589
@ Specialization
583
590
Object findGeneric (String self , String str , Object start , Object end ) throws ArithmeticException {
584
591
SliceInfo info = computeSlice (self .length (), start , end );
592
+ if (info .length == 0 ) {
593
+ return -1 ;
594
+ }
585
595
return findWithBounds (self , str , info .start , info .stop );
586
596
}
587
597
0 commit comments