@@ -61,6 +61,18 @@ internal func __NSDataIsCompact(_ data: NSData) -> Bool {
61
61
62
62
#endif
63
63
64
+ #if os(Windows)
65
+ @usableFromInline @discardableResult
66
+ internal func __withStackOrHeapBuffer( _ size: Int , _ block: ( UnsafeMutablePointer < _ConditionalAllocationBuffer > ) -> Void ) -> Bool {
67
+ return _withStackOrHeapBuffer ( size, block)
68
+ }
69
+ #else
70
+ @inlinable @inline ( __always) @discardableResult
71
+ internal func __withStackOrHeapBuffer( _ size: Int , _ block: ( UnsafeMutablePointer < _ConditionalAllocationBuffer > ) -> Void ) -> Bool {
72
+ return _withStackOrHeapBuffer ( size, block)
73
+ }
74
+ #endif
75
+
64
76
// Underlying storage representation for medium and large data.
65
77
// Inlinability strategy: methods from here should not inline into InlineSlice or LargeSlice unless trivial.
66
78
// NOTE: older overlays called this class _DataStorage. The two must
@@ -2048,7 +2060,7 @@ public struct Data : ReferenceConvertible, Equatable, Hashable, RandomAccessColl
2048
2060
}
2049
2061
2050
2062
}
2051
-
2063
+
2052
2064
// slightly faster paths for common sequences
2053
2065
@inlinable // This is @inlinable as an important generic funnel point, despite being a non-trivial initializer.
2054
2066
public init < S: Sequence > ( _ elements: S ) where S. Element == UInt8 {
@@ -2072,7 +2084,7 @@ public struct Data : ReferenceConvertible, Equatable, Hashable, RandomAccessColl
2072
2084
2073
2085
// Copy as much as we can in one shot from the sequence.
2074
2086
let underestimatedCount = Swift . max ( elements. underestimatedCount, 1 )
2075
- _withStackOrHeapBuffer ( underestimatedCount) { ( buffer) in
2087
+ __withStackOrHeapBuffer ( underestimatedCount) { ( buffer) in
2076
2088
// In order to copy from the sequence, we have to bind the buffer to UInt8.
2077
2089
// This is safe since we'll copy out of this buffer as raw memory later.
2078
2090
let capacity = buffer. pointee. capacity
@@ -2365,7 +2377,7 @@ public struct Data : ReferenceConvertible, Equatable, Hashable, RandomAccessColl
2365
2377
// The sequence is really not contiguous.
2366
2378
// Copy as much as we can in one shot.
2367
2379
let underestimatedCount = Swift . max ( elements. underestimatedCount, 1 )
2368
- _withStackOrHeapBuffer ( underestimatedCount) { ( buffer) in
2380
+ __withStackOrHeapBuffer ( underestimatedCount) { ( buffer) in
2369
2381
// In order to copy from the sequence, we have to bind the temporary buffer to `UInt8`.
2370
2382
// This is safe since we're the only owners of the buffer and we copy out as raw memory below anyway.
2371
2383
let capacity = buffer. pointee. capacity
@@ -2444,7 +2456,7 @@ public struct Data : ReferenceConvertible, Equatable, Hashable, RandomAccessColl
2444
2456
@inlinable // This is @inlinable as generic and reasonably small.
2445
2457
public mutating func replaceSubrange< ByteCollection : Collection > ( _ subrange: Range < Index > , with newElements: ByteCollection ) where ByteCollection. Iterator. Element == Data . Iterator . Element {
2446
2458
let totalCount = Int ( newElements. count)
2447
- _withStackOrHeapBuffer ( totalCount) { conditionalBuffer in
2459
+ __withStackOrHeapBuffer ( totalCount) { conditionalBuffer in
2448
2460
let buffer = UnsafeMutableBufferPointer ( start: conditionalBuffer. pointee. memory. assumingMemoryBound ( to: UInt8 . self) , count: totalCount)
2449
2461
var ( iterator, index) = newElements. _copyContents ( initializing: buffer)
2450
2462
while let byte = iterator. next ( ) {
0 commit comments