mirror of
https://github.com/apple/swift-collections
synced 2026-11-26 04:47:48 +00:00
ManagedBuffer.capacity is unavailable on OpenBSD.
ManagedBuffer.capacity depends on malloc introspection (e.g., `malloc_size`), which is not available on this platform -- and is thus marked as such. Here, _HashNode.Storage is a ManagedBuffer. Thankfully, the uses of .capacity are fairly limited: one for statistic purposes, which we just completely omit on the platform, and the other, setting a minimum capacity in the header by the buffer's .capacity; the alternative being setting that minimum capacity directly.
This commit is contained in:
1 parent
0495c7b6a1
commit
8bbbe287c3
2 files changed
+8
-1
No files matched your search
@@ -92,10 +92,15 @@ extension _HashNode.Storage {
|
||||
bytes += itemAlignment - childAlignment
|
||||
}
|
||||
|
||||
let mincap = (bytes &+ childStride &- 1) / childStride
|
||||
let object = _HashNode.Storage.create(
|
||||
minimumCapacity: (bytes &+ childStride &- 1) / childStride
|
||||
minimumCapacity: mincap
|
||||
) { buffer in
|
||||
#if os(OpenBSD)
|
||||
_HashNodeHeader(byteCapacity: mincap * childStride)
|
||||
#else
|
||||
_HashNodeHeader(byteCapacity: buffer.capacity * childStride)
|
||||
#endif
|
||||
}
|
||||
|
||||
object.withUnsafeMutablePointers { header, elements in
|
||||
|
||||
Reference in new issue
Block a user