File tree Expand file tree Collapse file tree 2 files changed +13
-2
lines changed Expand file tree Collapse file tree 2 files changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -386,8 +386,13 @@ extension Array {
386
386
_ index: Int , wasNativeTypeChecked: Bool
387
387
) -> _DependenceToken {
388
388
#if _runtime(_ObjC)
389
- _buffer. _checkInoutAndNativeTypeCheckedBounds (
390
- index, wasNativeTypeChecked: wasNativeTypeChecked)
389
+ // There is no need to do bounds checking for the non-native case because
390
+ // ObjectiveC arrays do bounds checking by their own.
391
+ // And in the native-non-type-checked case, it's also not needed to do bounds
392
+ // checking here, because it's done in ArrayBuffer._getElementSlowPath.
393
+ if _fastPath ( wasNativeTypeChecked) {
394
+ _buffer. _native. _checkValidSubscript ( index)
395
+ }
391
396
#else
392
397
_buffer. _checkValidSubscript ( index)
393
398
#endif
Original file line number Diff line number Diff line change @@ -422,6 +422,9 @@ extension _ArrayBuffer {
422
422
/// wasNative == _isNative in the absence of inout violations.
423
423
/// Because the optimizer can hoist the original check it might have
424
424
/// been invalidated by illegal user code.
425
+ ///
426
+ /// This function is obsolete but must stay in the library for backward
427
+ /// compatibility.
425
428
@inlinable
426
429
internal func _checkInoutAndNativeBounds( _ index: Int , wasNative: Bool ) {
427
430
_precondition (
@@ -439,6 +442,9 @@ extension _ArrayBuffer {
439
442
/// wasNativeTypeChecked == _isNativeTypeChecked in the absence of
440
443
/// inout violations. Because the optimizer can hoist the original
441
444
/// check it might have been invalidated by illegal user code.
445
+ ///
446
+ /// This function is obsolete but must stay in the library for backward
447
+ /// compatibility.
442
448
@inlinable
443
449
internal func _checkInoutAndNativeTypeCheckedBounds(
444
450
_ index: Int , wasNativeTypeChecked: Bool
You can’t perform that action at this time.
0 commit comments