@@ -17,7 +17,7 @@ import Darwin
17
17
#elseif os(Linux)
18
18
import Glibc
19
19
20
- @inlinable // This is @inlinable as trivially computable.
20
+ @usableFromInline // This is @inlinable as trivially computable.
21
21
fileprivate func malloc_good_size( _ size: Int ) -> Int {
22
22
return size
23
23
}
@@ -767,7 +767,7 @@ public struct Data : ReferenceConvertible, Equatable, Hashable, RandomAccessColl
767
767
}
768
768
769
769
let _ = Swift . withUnsafeMutableBytes ( of: & bytes) { rawBuffer in
770
- memset ( rawBuffer. baseAddress? . advanced ( by: range. lowerBound) , 0 , range. upperBound - range. lowerBound)
770
+ memset ( rawBuffer. baseAddress! . advanced ( by: range. lowerBound) , 0 , range. upperBound - range. lowerBound)
771
771
}
772
772
}
773
773
@@ -786,10 +786,10 @@ public struct Data : ReferenceConvertible, Equatable, Hashable, RandomAccessColl
786
786
let start = subrange. lowerBound
787
787
let length = subrange. upperBound - subrange. lowerBound
788
788
if shift != 0 {
789
- memmove ( mutableBytes. baseAddress? . advanced ( by: start + replacementLength) , mutableBytes. baseAddress? . advanced ( by: start + length) , currentLength - start - length)
789
+ memmove ( mutableBytes. baseAddress! . advanced ( by: start + replacementLength) , mutableBytes. baseAddress! . advanced ( by: start + length) , currentLength - start - length)
790
790
}
791
791
if replacementLength != 0 {
792
- memmove ( mutableBytes. baseAddress? . advanced ( by: start) , replacementBytes!, replacementLength)
792
+ memmove ( mutableBytes. baseAddress! . advanced ( by: start) , replacementBytes!, replacementLength)
793
793
}
794
794
}
795
795
count = resultingLength
@@ -1930,8 +1930,10 @@ public struct Data : ReferenceConvertible, Equatable, Hashable, RandomAccessColl
1930
1930
@inlinable // This is @inlinable as a convenience initializer.
1931
1931
public init ( repeating repeatedValue: UInt8 , count: Int ) {
1932
1932
self . init ( count: count)
1933
- withUnsafeMutableBytes { ( buffer: UnsafeMutableRawBufferPointer ) -> Void in
1934
- memset ( buffer. baseAddress, Int32 ( repeatedValue) , buffer. count)
1933
+ if count > 0 {
1934
+ withUnsafeMutableBytes { ( buffer: UnsafeMutableRawBufferPointer ) -> Void in
1935
+ memset ( buffer. baseAddress!, Int32 ( repeatedValue) , buffer. count)
1936
+ }
1935
1937
}
1936
1938
}
1937
1939
@@ -2606,9 +2608,10 @@ public struct Data : ReferenceConvertible, Equatable, Hashable, RandomAccessColl
2606
2608
public func _copyContents( initializing buffer: UnsafeMutableBufferPointer < UInt8 > ) -> ( Iterator , UnsafeMutableBufferPointer < UInt8 > . Index ) {
2607
2609
guard !isEmpty else { return ( makeIterator ( ) , buffer. startIndex) }
2608
2610
let cnt = Swift . min ( count, buffer. count)
2609
-
2610
- withUnsafeBytes { ( bytes: UnsafeRawBufferPointer ) in
2611
- _ = memcpy ( UnsafeMutableRawPointer ( buffer. baseAddress) , bytes. baseAddress, cnt)
2611
+ if cnt > 0 {
2612
+ withUnsafeBytes { ( bytes: UnsafeRawBufferPointer ) in
2613
+ _ = memcpy ( UnsafeMutableRawPointer ( buffer. baseAddress!) , bytes. baseAddress!, cnt)
2614
+ }
2612
2615
}
2613
2616
2614
2617
return ( Iterator ( self , at: startIndex + cnt) , buffer. index ( buffer. startIndex, offsetBy: cnt) )
0 commit comments