Skip to content

Commit 5818041

Browse files
authored
Merge pull request swiftlang#127 from apple/revert-125-SE-0101
Revert "[SE-0101] Migration"
2 parents af84b9c + fdc96f2 commit 5818041

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/swift/Data.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public struct DispatchData : RandomAccessCollection {
8080
var size = 0
8181
let data = CDispatch.dispatch_data_create_map(__wrapped.__wrapped, &ptr, &size)
8282
let contentPtr = ptr!.bindMemory(
83-
to: ContentType.self, capacity: size / MemoryLayout<ContentType>.stride)
83+
to: ContentType.self, capacity: size / strideof(ContentType.self))
8484
defer { _fixLifetime(data) }
8585
return try body(contentPtr)
8686
}
@@ -118,7 +118,7 @@ public struct DispatchData : RandomAccessCollection {
118118
///
119119
/// - parameter buffer: The buffer of bytes to append. The size is calculated from `SourceType` and `buffer.count`.
120120
public mutating func append<SourceType>(_ buffer : UnsafeBufferPointer<SourceType>) {
121-
self.append(UnsafePointer(buffer.baseAddress!), count: buffer.count * MemoryLayout<SourceType>.stride)
121+
self.append(UnsafePointer(buffer.baseAddress!), count: buffer.count * sizeof(SourceType.self))
122122
}
123123

124124
private func _copyBytesHelper(to pointer: UnsafeMutablePointer<UInt8>, from range: CountableRange<Index>) {
@@ -151,7 +151,7 @@ public struct DispatchData : RandomAccessCollection {
151151

152152
/// Copy the contents of the data into a buffer.
153153
///
154-
/// This function copies the bytes in `range` from the data into the buffer. If the count of the `range` is greater than `MemoryLayout<DestinationType>.size * buffer.count` then the first N bytes will be copied into the buffer.
154+
/// This function copies the bytes in `range` from the data into the buffer. If the count of the `range` is greater than `sizeof(DestinationType) * buffer.count` then the first N bytes will be copied into the buffer.
155155
/// - precondition: The range must be within the bounds of the data. Otherwise `fatalError` is called.
156156
/// - parameter buffer: A buffer to copy the data into.
157157
/// - parameter range: A range in the data to copy into the buffer. If the range is empty, this function will return 0 without copying anything. If the range is nil, as much data as will fit into `buffer` is copied.
@@ -169,9 +169,9 @@ public struct DispatchData : RandomAccessCollection {
169169
precondition(r.endIndex >= 0)
170170
precondition(r.endIndex <= cnt, "The range is outside the bounds of the data")
171171

172-
copyRange = r.startIndex..<(r.startIndex + Swift.min(buffer.count * MemoryLayout<DestinationType>.stride, r.count))
172+
copyRange = r.startIndex..<(r.startIndex + Swift.min(buffer.count * sizeof(DestinationType.self), r.count))
173173
} else {
174-
copyRange = 0..<Swift.min(buffer.count * MemoryLayout<DestinationType>.stride, cnt)
174+
copyRange = 0..<Swift.min(buffer.count * sizeof(DestinationType.self), cnt)
175175
}
176176

177177
guard !copyRange.isEmpty else { return 0 }

0 commit comments

Comments
 (0)