@@ -367,6 +367,7 @@ extension Span where Element: ~Copyable {
367367 ///
368368 /// - Complexity: O(1)
369369 @_alwaysEmitIntoClient
370+ @_semantics ( " fixed_storage.get_count " )
370371 public var count : Int { _count }
371372
372373 /// A Boolean value indicating whether the span is empty.
@@ -390,6 +391,12 @@ extension Span where Element: ~Copyable {
390391
391392@available ( SwiftStdlib 6 . 1 , * )
392393extension Span where Element: ~ Copyable {
394+ @_semantics ( " fixed_storage.check_index " )
395+ @inline ( __always)
396+ @_alwaysEmitIntoClient
397+ internal func _checkIndex( _ position: Index ) {
398+ _precondition ( indices. contains ( position) , " Index out of bounds " )
399+ }
393400
394401 /// Accesses the element at the specified position in the `Span`.
395402 ///
@@ -401,7 +408,7 @@ extension Span where Element: ~Copyable {
401408 public subscript( _ position: Index) - > Element {
402409 //FIXME: change to unsafeRawAddress when ready
403410 unsafeAddress {
404- _precondition ( indices . contains ( position) , " Index out of bounds " )
411+ _checkIndex ( position)
405412 return unsafe _unsafeAddressOfElement( unchecked: position)
406413 }
407414 }
@@ -437,6 +444,15 @@ extension Span where Element: ~Copyable {
437444
438445@available ( SwiftStdlib 6 . 1 , * )
439446extension Span where Element: BitwiseCopyable {
447+ @_semantics ( " fixed_storage.check_index " )
448+ @inline ( __always)
449+ @_alwaysEmitIntoClient
450+ internal func _checkIndex( _ position: Index ) {
451+ _precondition (
452+ UInt ( bitPattern: position) < UInt ( bitPattern: _count) ,
453+ " Index out of bounds "
454+ )
455+ }
440456
441457 /// Accesses the element at the specified position in the `Span`.
442458 ///
@@ -447,10 +463,7 @@ extension Span where Element: BitwiseCopyable {
447463 @_alwaysEmitIntoClient
448464 public subscript( _ position: Index ) -> Element {
449465 get {
450- _precondition (
451- UInt ( bitPattern: position) < UInt ( bitPattern: _count) ,
452- " Index out of bounds "
453- )
466+ _checkIndex ( position)
454467 return unsafe self[ unchecked: position]
455468 }
456469 }
0 commit comments