Skip to content

Commit 7120279

Browse files
committed
[embedded] Avoid using a metatype variable in _allocateUninitializedArray
1 parent 92c20a6 commit 7120279

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

stdlib/public/core/ArrayShared.swift

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,13 @@ func _allocateUninitializedArray<Element>(_ builtinCount: Builtin.Word)
4141
if count > 0 {
4242
// Doing the actual buffer allocation outside of the array.uninitialized
4343
// semantics function enables stack propagation of the buffer.
44-
let storageType: _ContiguousArrayStorage<Element>.Type
4544
#if !$Embedded
46-
storageType = getContiguousArrayStorageType(for: Element.self)
45+
let bufferObject = Builtin.allocWithTailElems_1(
46+
getContiguousArrayStorageType(for: Element.self), builtinCount, Element.self)
4747
#else
48-
storageType = _ContiguousArrayStorage<Element>.self
49-
#endif
5048
let bufferObject = Builtin.allocWithTailElems_1(
51-
storageType, builtinCount, Element.self)
49+
_ContiguousArrayStorage<Element>.self, builtinCount, Element.self)
50+
#endif
5251

5352
let (array, ptr) = Array<Element>._adoptStorage(bufferObject, count: count)
5453
return (array, ptr._rawValue)

0 commit comments

Comments
 (0)