mirror of
https://github.com/apple/swift-collections
synced 2026-11-24 04:27:53 +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
@@ -115,12 +115,14 @@ extension _HashNode {
|
||||
|
||||
let objectHeaderSize = 2 * MemoryLayout<Int>.stride
|
||||
|
||||
#if !os(OpenBSD)
|
||||
// Note: for simplicity, we assume that there is no padding between
|
||||
// the object header and the storage header.
|
||||
let start = _getUnsafePointerToStoredProperties(self.raw.storage)
|
||||
let capacity = self.raw.storage.capacity
|
||||
let end = $0._memory + capacity * MemoryLayout<_RawHashNode>.stride
|
||||
stats.grossBytes += objectHeaderSize + (end - start)
|
||||
#endif
|
||||
|
||||
for child in $0.children {
|
||||
child.gatherStatistics(level.descend(), &stats)
|
||||
|
||||
Reference in new issue
Block a user