Skip to content

Commit 2a9aa16

Browse files
committed
Make empty dictionary literals use the singleton
1 parent 9bc5bd2 commit 2a9aa16

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

stdlib/public/core/NativeDictionary.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,11 @@ internal struct _NativeDictionary<Key: Hashable, Value> {
3737

3838
@inlinable
3939
internal init(capacity: Int) {
40-
self._storage = _DictionaryStorage<Key, Value>.allocate(capacity: capacity)
40+
if capacity == 0 {
41+
self._storage = __RawDictionaryStorage.empty
42+
} else {
43+
self._storage = _DictionaryStorage<Key, Value>.allocate(capacity: capacity)
44+
}
4145
}
4246

4347
#if _runtime(_ObjC)

0 commit comments

Comments
 (0)