Skip to content

Commit bf09c28

Browse files
committed
Make empty set literals use the singleton
1 parent 2a9aa16 commit bf09c28

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

stdlib/public/core/NativeSet.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,11 @@ internal struct _NativeSet<Element: Hashable> {
3636

3737
@inlinable
3838
internal init(capacity: Int) {
39-
self._storage = _SetStorage<Element>.allocate(capacity: capacity)
39+
if capacity == 0 {
40+
self._storage = __RawSetStorage.empty
41+
} else {
42+
self._storage = _SetStorage<Element>.allocate(capacity: capacity)
43+
}
4044
}
4145

4246
#if _runtime(_ObjC)

0 commit comments

Comments
 (0)