@@ -314,8 +314,8 @@ internal final class _DataStorage {
314
314
func append( _ otherData: Data ) {
315
315
guard otherData. count > 0 else { return }
316
316
otherData. withUnsafeBytes {
317
- append ( $0. baseAddress!, length: $0. count)
318
- }
317
+ append ( $0. baseAddress!, length: $0. count)
318
+ }
319
319
}
320
320
321
321
@inlinable
@@ -759,10 +759,10 @@ public struct Data : ReferenceConvertible, Equatable, Hashable, RandomAccessColl
759
759
@inlinable
760
760
var count : Int {
761
761
get {
762
- return numericCast ( length)
762
+ return Int ( length)
763
763
}
764
764
set ( newValue) {
765
- precondition ( newValue <= MemoryLayout< Buffer> . size)
765
+ assert ( newValue <= MemoryLayout< Buffer> . size)
766
766
length = UInt8 ( newValue)
767
767
}
768
768
}
@@ -775,15 +775,15 @@ public struct Data : ReferenceConvertible, Equatable, Hashable, RandomAccessColl
775
775
776
776
@inlinable
777
777
func withUnsafeBytes< Result> ( _ apply: ( UnsafeRawBufferPointer ) throws -> Result ) rethrows -> Result {
778
- let count : Int = numericCast ( length)
778
+ let count = Int ( length)
779
779
return try Swift . withUnsafeBytes ( of: bytes) { ( rawBuffer) throws -> Result in
780
780
return try apply ( UnsafeRawBufferPointer ( start: rawBuffer. baseAddress, count: count) )
781
781
}
782
782
}
783
783
784
784
@inlinable
785
785
mutating func withUnsafeMutableBytes< Result> ( _ apply: ( UnsafeMutableRawBufferPointer ) throws -> Result ) rethrows -> Result {
786
- let count : Int = numericCast ( length)
786
+ let count = Int ( length)
787
787
return try Swift . withUnsafeMutableBytes ( of: & bytes) { ( rawBuffer) throws -> Result in
788
788
return try apply ( UnsafeMutableRawBufferPointer ( start: rawBuffer. baseAddress, count: count) )
789
789
}
@@ -827,8 +827,8 @@ public struct Data : ReferenceConvertible, Equatable, Hashable, RandomAccessColl
827
827
if count < range. upperBound {
828
828
count = range. upperBound
829
829
}
830
- Swift . withUnsafeMutableBytes ( of: & bytes) { rawBuffer in
831
- bzero ( rawBuffer. baseAddress? . advanced ( by: range. lowerBound) , range. upperBound - range. lowerBound)
830
+ let _ = Swift . withUnsafeMutableBytes ( of: & bytes) { rawBuffer in
831
+ memset ( rawBuffer. baseAddress? . advanced ( by: range. lowerBound) , 0 , range. upperBound - range. lowerBound)
832
832
}
833
833
}
834
834
@@ -838,7 +838,7 @@ public struct Data : ReferenceConvertible, Equatable, Hashable, RandomAccessColl
838
838
assert ( subrange. upperBound <= MemoryLayout< Buffer> . size)
839
839
assert ( count - ( subrange. upperBound - subrange. lowerBound) + replacementLength <= MemoryLayout< Buffer> . size)
840
840
precondition ( subrange. lowerBound <= length, " index \( subrange. lowerBound) is out of bounds of 0..< \( length) " )
841
- precondition ( subrange. upperBound <= length, " index \( subrange. lowerBound ) is out of bounds of 0..< \( length) " )
841
+ precondition ( subrange. upperBound <= length, " index \( subrange. upperBound ) is out of bounds of 0..< \( length) " )
842
842
let currentLength = count
843
843
let resultingLength = currentLength - ( subrange. upperBound - subrange. lowerBound) + replacementLength
844
844
let shift = resultingLength - currentLength
@@ -872,7 +872,7 @@ public struct Data : ReferenceConvertible, Equatable, Hashable, RandomAccessColl
872
872
873
873
@inlinable
874
874
var hashValue : Int {
875
- let count : Int = numericCast ( length)
875
+ let count = Int ( length)
876
876
return Swift . withUnsafeBytes ( of: bytes) { ( rawBuffer) -> Int in
877
877
return Int ( bitPattern: CFHashBytes ( UnsafeMutablePointer ( mutating: rawBuffer. baseAddress? . assumingMemoryBound ( to: UInt8 . self) ) , count) )
878
878
}
@@ -972,9 +972,9 @@ public struct Data : ReferenceConvertible, Equatable, Hashable, RandomAccessColl
972
972
}
973
973
974
974
@inlinable
975
- var startIndex : Int { return numericCast ( slice. lowerBound) }
975
+ var startIndex : Int { return Int ( slice. lowerBound) }
976
976
@inlinable
977
- var endIndex : Int { return numericCast ( slice. upperBound) }
977
+ var endIndex : Int { return Int ( slice. upperBound) }
978
978
979
979
@inlinable
980
980
var capacity : Int {
@@ -991,7 +991,7 @@ public struct Data : ReferenceConvertible, Equatable, Hashable, RandomAccessColl
991
991
@inlinable
992
992
var count : Int {
993
993
get {
994
- return numericCast ( slice. upperBound - slice. lowerBound)
994
+ return Int ( slice. upperBound - slice. lowerBound)
995
995
}
996
996
set ( newValue) {
997
997
assert ( newValue < HalfInt . max)
@@ -1004,7 +1004,7 @@ public struct Data : ReferenceConvertible, Equatable, Hashable, RandomAccessColl
1004
1004
@inlinable
1005
1005
var range : Range < Int > {
1006
1006
get {
1007
- return numericCast ( slice. lowerBound) ..< numericCast ( slice. upperBound)
1007
+ return Int ( slice. lowerBound) ..< Int ( slice. upperBound)
1008
1008
}
1009
1009
set ( newValue) {
1010
1010
assert ( newValue. lowerBound < HalfInt . max)
@@ -1029,7 +1029,7 @@ public struct Data : ReferenceConvertible, Equatable, Hashable, RandomAccessColl
1029
1029
assert ( endIndex + buffer. count < HalfInt . max)
1030
1030
ensureUniqueReference ( )
1031
1031
storage. replaceBytes ( in: NSRange ( location: range. upperBound, length: storage. length - ( range. upperBound - storage. _offset) ) , with: buffer. baseAddress, length: buffer. count)
1032
- slice = slice. lowerBound..< HalfInt ( numericCast ( slice. upperBound) + buffer. count)
1032
+ slice = slice. lowerBound..< HalfInt ( Int ( slice. upperBound) + buffer. count)
1033
1033
}
1034
1034
1035
1035
@inlinable
@@ -2212,7 +2212,7 @@ public struct Data : ReferenceConvertible, Equatable, Hashable, RandomAccessColl
2212
2212
2213
2213
@inlinable
2214
2214
internal func _copyBytesHelper( to pointer: UnsafeMutableRawPointer , from range: Range < Int > ) {
2215
- if range. upperBound - range . lowerBound == 0 { return }
2215
+ if range. isEmpty { return }
2216
2216
_representation. copyBytes ( to: pointer, from: range)
2217
2217
}
2218
2218
@@ -2453,7 +2453,7 @@ public struct Data : ReferenceConvertible, Equatable, Hashable, RandomAccessColl
2453
2453
/// - parameter newElements: The replacement bytes.
2454
2454
@inlinable
2455
2455
public mutating func replaceSubrange< ByteCollection : Collection > ( _ subrange: Range < Index > , with newElements: ByteCollection ) where ByteCollection. Iterator. Element == Data . Iterator . Element {
2456
- let totalCount : Int = numericCast ( newElements. count)
2456
+ let totalCount = Int ( newElements. count)
2457
2457
_withStackOrHeapBuffer ( totalCount) { conditionalBuffer in
2458
2458
let buffer = UnsafeMutableBufferPointer ( start: conditionalBuffer. pointee. memory. assumingMemoryBound ( to: UInt8 . self) , count: totalCount)
2459
2459
var ( iterator, index) = newElements. _copyContents ( initializing: buffer)
@@ -2561,21 +2561,20 @@ public struct Data : ReferenceConvertible, Equatable, Hashable, RandomAccessColl
2561
2561
let lower = R . Bound ( startIndex)
2562
2562
let upper = R . Bound ( endIndex)
2563
2563
let range = rangeExpression. relative ( to: lower..< upper)
2564
- let start : Int = numericCast ( range. lowerBound)
2565
- let end : Int = numericCast ( range. upperBound)
2564
+ let start = Int ( range. lowerBound)
2565
+ let end = Int ( range. upperBound)
2566
2566
let r : Range < Int > = start..< end
2567
2567
return _representation [ r]
2568
2568
}
2569
2569
set {
2570
2570
let lower = R . Bound ( startIndex)
2571
2571
let upper = R . Bound ( endIndex)
2572
2572
let range = rangeExpression. relative ( to: lower..< upper)
2573
- let start : Int = numericCast ( range. lowerBound)
2574
- let end : Int = numericCast ( range. upperBound)
2573
+ let start = Int ( range. lowerBound)
2574
+ let end = Int ( range. upperBound)
2575
2575
let r : Range < Int > = start..< end
2576
2576
replaceSubrange ( r, with: newValue)
2577
2577
}
2578
-
2579
2578
}
2580
2579
2581
2580
/// The start `Index` in the data.
0 commit comments