@@ -503,6 +503,88 @@ public struct ${Self}<Element>
503
503
% end
504
504
}
505
505
506
+ @warn_unused_result
507
+ public func index( after i: Int ) -> Int {
508
+ // NOTE: this is a manual specialization of index movement for a Strideable
509
+ // index that is required for Array performance. The optimizer is not
510
+ // capable of creating partial specializations yet.
511
+ // NOTE: Range checks are not performed here, because it is done later by
512
+ // the subscript function.
513
+ return i + 1
514
+ }
515
+
516
+ public func formIndex( after i: inout Int ) {
517
+ // NOTE: this is a manual specialization of index movement for a Strideable
518
+ // index that is required for Array performance. The optimizer is not
519
+ // capable of creating partial specializations yet.
520
+ // NOTE: Range checks are not performed here, because it is done later by
521
+ // the subscript function.
522
+ i += 1
523
+ }
524
+
525
+ @warn_unused_result
526
+ public func index( before i: Int ) -> Int {
527
+ // NOTE: this is a manual specialization of index movement for a Strideable
528
+ // index that is required for Array performance. The optimizer is not
529
+ // capable of creating partial specializations yet.
530
+ // NOTE: Range checks are not performed here, because it is done later by
531
+ // the subscript function.
532
+ return i - 1
533
+ }
534
+
535
+ public func formIndex( before i: inout Int ) {
536
+ // NOTE: this is a manual specialization of index movement for a Strideable
537
+ // index that is required for Array performance. The optimizer is not
538
+ // capable of creating partial specializations yet.
539
+ // NOTE: Range checks are not performed here, because it is done later by
540
+ // the subscript function.
541
+ i -= 1
542
+ }
543
+
544
+ @warn_unused_result
545
+ public func index( _ i: Int , offsetBy n: Int ) -> Int {
546
+ // NOTE: this is a manual specialization of index movement for a Strideable
547
+ // index that is required for Array performance. The optimizer is not
548
+ // capable of creating partial specializations yet.
549
+ // NOTE: Range checks are not performed here, because it is done later by
550
+ // the subscript function.
551
+ return i + n
552
+ }
553
+
554
+ @warn_unused_result
555
+ public func index(
556
+ _ i: Int , offsetBy n: Int , limitedBy limit: Int
557
+ ) -> Int ? {
558
+ // NOTE: this is a manual specialization of index movement for a Strideable
559
+ // index that is required for Array performance. The optimizer is not
560
+ // capable of creating partial specializations yet.
561
+ // NOTE: Range checks are not performed here, because it is done later by
562
+ // the subscript function.
563
+ let l = limit - i
564
+ if n > 0 ? l >= 0 && l < n : l <= 0 && n < l {
565
+ return nil
566
+ }
567
+ return i + n
568
+ }
569
+
570
+ @warn_unused_result
571
+ public func distance( from start: Int , to end: Int ) -> Int {
572
+ // NOTE: this is a manual specialization of index movement for a Strideable
573
+ // index that is required for Array performance. The optimizer is not
574
+ // capable of creating partial specializations yet.
575
+ // NOTE: Range checks are not performed here, because it is done later by
576
+ // the subscript function.
577
+ return end - start
578
+ }
579
+
580
+ public func _failEarlyRangeCheck( _ index: Int , bounds: Range < Int > ) {
581
+ // NOTE: This method is a no-op for performance reasons.
582
+ }
583
+
584
+ public func _failEarlyRangeCheck( _ range: Range < Int > , bounds: Range < Int > ) {
585
+ // NOTE: This method is a no-op for performance reasons.
586
+ }
587
+
506
588
public typealias Indices = CountableRange < Int >
507
589
508
590
% {
0 commit comments