Skip to content

Commit 1ccc36c

Browse files
authored
Merge pull request swiftlang#61082 from glessard/source-equals-destination
2 parents b6ececb + 874cd33 commit 1ccc36c

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

stdlib/public/core/UnsafePointer.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -861,6 +861,8 @@ public struct UnsafeMutablePointer<Pointee>: _Pointer {
861861
/// `moveInitialize(from:count:)`, the region is initialized and the memory
862862
/// region `source..<(source + count)` is uninitialized.
863863
///
864+
/// - Note: Returns without performing work if `self` and `source` are equal.
865+
///
864866
/// - Parameters:
865867
/// - source: A pointer to the values to copy. The memory region
866868
/// `source..<(source + count)` must be initialized. The memory regions
@@ -882,7 +884,7 @@ public struct UnsafeMutablePointer<Pointee>: _Pointer {
882884
// (self + i).initialize(to: (source + i).move())
883885
// }
884886
}
885-
else {
887+
else if self != source {
886888
// initialize backward from a non-following overlapping range.
887889
Builtin.takeArrayBackToFront(
888890
Pointee.self, self._rawValue, source._rawValue, count._builtinWordValue)

0 commit comments

Comments
 (0)