@@ -599,26 +599,8 @@ extension Unsafe${Mutable}BufferPointer {
599
599
@inlinable // unsafe-performance
600
600
public static func allocate( capacity count: Int)
601
601
- > UnsafeMutableBufferPointer< Element> {
602
- let size = MemoryLayout < Element > . stride * count
603
- // For any alignment <= _minAllocationAlignment, force alignment = 0.
604
- // This forces the runtime's "aligned" allocation path so that
605
- // deallocation does not require the original alignment.
606
- //
607
- // The runtime guarantees:
608
- //
609
- // align == 0 || align > _minAllocationAlignment:
610
- // Runtime uses "aligned allocation".
611
- //
612
- // 0 < align <= _minAllocationAlignment:
613
- // Runtime may use either malloc or "aligned allocation".
614
- var align = Builtin . alignof ( Element . self)
615
- if Int ( align) <= _minAllocationAlignment ( ) {
616
- align = ( 0 ) . _builtinWordValue
617
- }
618
- let raw = Builtin . allocRaw ( size. _builtinWordValue, align)
619
- Builtin . bindMemory ( raw, count. _builtinWordValue, Element . self)
620
- return UnsafeMutableBufferPointer (
621
- start: UnsafeMutablePointer ( raw) , count: count)
602
+ let base = UnsafeMutablePointer< Element> . allocate( capacity: count)
603
+ return UnsafeMutableBufferPointer ( start: base, count: count)
622
604
}
623
605
624
606
/// Initializes every element in this buffer's memory to a copy of the given value.
0 commit comments