mirror of
https://github.com/apple/swift-collections
synced 2026-11-27 04:54:21 +00:00
[SortedCollections] Fix _BTree default node capacity capping at 16
The defaultInternalCapacity and defaultLeafCapacity computations used Swift.min(16, capacityInBytes / MemoryLayout<Key>.stride), which capped the node capacity at 16 regardless of element size. This defeated the byte-budget intent: small elements should yield larger nodes, not be clamped to 16. Use Swift.max instead so 16 acts as a floor and the byte budget governs the upper bound, as confirmed by the maintainer in issue #257. Fixes #257
This commit is contained in:
1 file changed
+2
-2
@@ -31,7 +31,7 @@ internal struct _BTree<Key: Comparable, Value> {
|
||||
return 4
|
||||
#else
|
||||
let capacityInBytes = 128
|
||||
return Swift.min(16, capacityInBytes / MemoryLayout<Key>.stride)
|
||||
return Swift.max(16, capacityInBytes / MemoryLayout<Key>.stride)
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ internal struct _BTree<Key: Comparable, Value> {
|
||||
return 5
|
||||
#else
|
||||
let capacityInBytes = 2000
|
||||
return Swift.min(16, capacityInBytes / MemoryLayout<Key>.stride)
|
||||
return Swift.max(16, capacityInBytes / MemoryLayout<Key>.stride)
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user