@@ -57,6 +57,83 @@ public struct Unsafe${Mutable}BufferPointer<Element>
57
57
return count
58
58
}
59
59
60
+ public func index( after i: Int ) -> Int {
61
+ // NOTE: this is a manual specialization of index movement for a Strideable
62
+ // index that is required for UnsafeBufferPointer performance. The
63
+ // optimizer is not capable of creating partial specializations yet.
64
+ // NOTE: Range checks are not performed here, because it is done later by
65
+ // the subscript function.
66
+ return i + 1
67
+ }
68
+
69
+ public func formIndex( after i: inout Int ) {
70
+ // NOTE: this is a manual specialization of index movement for a Strideable
71
+ // index that is required for UnsafeBufferPointer performance. The
72
+ // optimizer is not capable of creating partial specializations yet.
73
+ // NOTE: Range checks are not performed here, because it is done later by
74
+ // the subscript function.
75
+ i += 1
76
+ }
77
+
78
+ public func index( before i: Int ) -> Int {
79
+ // NOTE: this is a manual specialization of index movement for a Strideable
80
+ // index that is required for UnsafeBufferPointer performance. The
81
+ // optimizer is not capable of creating partial specializations yet.
82
+ // NOTE: Range checks are not performed here, because it is done later by
83
+ // the subscript function.
84
+ return i - 1
85
+ }
86
+
87
+ public func formIndex( before i: inout Int ) {
88
+ // NOTE: this is a manual specialization of index movement for a Strideable
89
+ // index that is required for UnsafeBufferPointer performance. The
90
+ // optimizer is not capable of creating partial specializations yet.
91
+ // NOTE: Range checks are not performed here, because it is done later by
92
+ // the subscript function.
93
+ i -= 1
94
+ }
95
+
96
+ public func index( _ i: Int , offsetBy n: Int ) -> Int {
97
+ // NOTE: this is a manual specialization of index movement for a Strideable
98
+ // index that is required for UnsafeBufferPointer performance. The
99
+ // optimizer is not capable of creating partial specializations yet.
100
+ // NOTE: Range checks are not performed here, because it is done later by
101
+ // the subscript function.
102
+ return i + n
103
+ }
104
+
105
+ public func index(
106
+ _ i: Int , offsetBy n: Int , limitedBy limit: Int
107
+ ) -> Int ? {
108
+ // NOTE: this is a manual specialization of index movement for a Strideable
109
+ // index that is required for UnsafeBufferPointer performance. The
110
+ // optimizer is not capable of creating partial specializations yet.
111
+ // NOTE: Range checks are not performed here, because it is done later by
112
+ // the subscript function.
113
+ let l = limit - i
114
+ if n > 0 ? l >= 0 && l < n : l <= 0 && n < l {
115
+ return nil
116
+ }
117
+ return i + n
118
+ }
119
+
120
+ public func distance( from start: Int , to end: Int ) -> Int {
121
+ // NOTE: this is a manual specialization of index movement for a Strideable
122
+ // index that is required for UnsafeBufferPointer performance. The
123
+ // optimizer is not capable of creating partial specializations yet.
124
+ // NOTE: Range checks are not performed here, because it is done later by
125
+ // the subscript function.
126
+ return end - start
127
+ }
128
+
129
+ public func _failEarlyRangeCheck( _ index: Int , bounds: Range < Int > ) {
130
+ // NOTE: This method is a no-op for performance reasons.
131
+ }
132
+
133
+ public func _failEarlyRangeCheck( _ range: Range < Int > , bounds: Range < Int > ) {
134
+ // NOTE: This method is a no-op for performance reasons.
135
+ }
136
+
60
137
public typealias Indices = CountableRange < Int >
61
138
62
139
public var indices : Indices {
0 commit comments