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 {
386386 _ index: Int , wasNativeTypeChecked: Bool
387387 ) -> _DependenceToken {
388388#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+ }
391396#else
392397 _buffer. _checkValidSubscript ( index)
393398#endif
Original file line number Diff line number Diff line change @@ -422,6 +422,9 @@ extension _ArrayBuffer {
422422 /// wasNative == _isNative in the absence of inout violations.
423423 /// Because the optimizer can hoist the original check it might have
424424 /// been invalidated by illegal user code.
425+ ///
426+ /// This function is obsolete but must stay in the library for backward
427+ /// compatibility.
425428 @inlinable
426429 internal func _checkInoutAndNativeBounds( _ index: Int , wasNative: Bool ) {
427430 _precondition (
@@ -439,6 +442,9 @@ extension _ArrayBuffer {
439442 /// wasNativeTypeChecked == _isNativeTypeChecked in the absence of
440443 /// inout violations. Because the optimizer can hoist the original
441444 /// 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.
442448 @inlinable
443449 internal func _checkInoutAndNativeTypeCheckedBounds(
444450 _ index: Int , wasNativeTypeChecked: Bool
You can’t perform that action at this time.
0 commit comments