Skip to content

Commit 41769e1

Browse files
committed
[stdlib] remove the single-element update functions
- as per an update to the proposal
1 parent 54941cc commit 41769e1

File tree

4 files changed

+4
-61
lines changed

4 files changed

+4
-61
lines changed

stdlib/public/core/UnsafeBufferPointer.swift.gyb

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -938,24 +938,6 @@ extension Unsafe${Mutable}BufferPointer {
938938
p.initialize(to: value)
939939
}
940940

941-
/// Updates the initialized element at `index` to the given value.
942-
///
943-
/// The memory underlying the destination element must be initialized,
944-
/// or `Element` must be a trivial type. This method is equivalent to:
945-
///
946-
/// self[index] = value
947-
///
948-
/// - Parameters:
949-
/// - value: The value used to update the buffer element's memory.
950-
/// - index: The index of the element to update
951-
@inlinable
952-
@_alwaysEmitIntoClient
953-
public func updateElement(at index: Index, to value: Element) {
954-
precondition(startIndex <= index && index < endIndex)
955-
let p = baseAddress._unsafelyUnwrappedUnchecked.advanced(by: index)
956-
p.pointee = value
957-
}
958-
959941
/// Retrieves and returns the element at `index`,
960942
/// leaving that element's underlying memory uninitialized.
961943
///

stdlib/public/core/UnsafeBufferPointerSlice.swift

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -950,24 +950,6 @@ extension Slice {
950950
base.baseAddress.unsafelyUnwrapped.advanced(by: index).initialize(to: value)
951951
}
952952

953-
/// Updates the initialized element at `index` to the given value.
954-
///
955-
/// The memory underlying the destination element must be initialized,
956-
/// or `Element` must be a trivial type. This method is equivalent to:
957-
///
958-
/// self[index] = value
959-
///
960-
/// - Parameters:
961-
/// - value: The value used to update the buffer element's memory.
962-
/// - index: The index of the element to update
963-
@inlinable
964-
@_alwaysEmitIntoClient
965-
public func updateElement<Element>(at index: Index, to value: Element)
966-
where Base == UnsafeMutableBufferPointer<Element> {
967-
assert(startIndex <= index && index < endIndex)
968-
base.baseAddress.unsafelyUnwrapped.advanced(by: index).pointee = value
969-
}
970-
971953
/// Retrieves and returns the element at `index`,
972954
/// leaving that element's underlying memory uninitialized.
973955
///

stdlib/public/core/UnsafePointer.swift

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -792,22 +792,6 @@ public struct UnsafeMutablePointer<Pointee>: _Pointer {
792792
update(repeating: repeatedValue, count: count)
793793
}
794794

795-
/// Update this pointer's initialized memory.
796-
///
797-
/// The range of memory starting at this pointer and covering one instance
798-
/// of `Pointee` must be initialized, or `Pointee` must be a trivial type.
799-
/// This method is equivalent to:
800-
///
801-
/// self.pointee = value
802-
///
803-
/// - Parameters:
804-
/// - value: The value used to update this pointer's memory.
805-
@inlinable
806-
@_alwaysEmitIntoClient
807-
public func update(_ value: Pointee) {
808-
pointee = value
809-
}
810-
811795
/// Update this pointer's initialized memory with the specified number of
812796
/// instances, copied from the given pointer's memory.
813797
///

validation-test/stdlib/UnsafeBufferPointerSlices.swift

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -263,17 +263,12 @@ UnsafeMutableBufferPointerSliceTests.test(
263263
b[...].initializeElement(at: n, to: s)
264264
expectEqual(b[n], s)
265265

266-
a.updateElement(at: n, to: t)
267-
expectEqual(a[n], t)
268-
b[...].initializeElement(at: n, to: t)
269-
expectEqual(b[n], t)
266+
expectEqual(a.moveElement(from: n), s)
267+
expectEqual(b[...].moveElement(from: n), s)
270268

271-
expectEqual(a.moveElement(from: n), t)
272-
expectEqual(b[...].moveElement(from: n), t)
273-
274-
a.initializeElement(at: 0, to: s)
269+
a.initializeElement(at: 0, to: t)
275270
a.deinitializeElement(at: 0)
276-
b.initializeElement(at: 0, to: s)
271+
b.initializeElement(at: 0, to: t)
277272
b[...].deinitializeElement(at: 0)
278273
}
279274

0 commit comments

Comments
 (0)