Skip to content

[SE-0370] pointer family initialization improvements & better buffer slices #41608

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 45 commits into from
Sep 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
304a422
[stdlib] add single-element assign to UnsafeMutablePointer
glessard Oct 19, 2021
a7326d0
[gardening] improve doc-comments in UnsafeMutablePointer
glessard Nov 11, 2021
99d957f
[gardening] improve summary line
glessard Oct 20, 2021
94d5387
[gardening] remove outdated recommendation
glessard Oct 20, 2021
cff3012
[stdlib] additions to UMBP
glessard Mar 1, 2022
bef793d
[stdlib] add single-element version of `initializeMemory` to UMRP
glessard Oct 22, 2021
2e3b5e6
[stdlib] more memory initialization functions for UMRBP
glessard Mar 1, 2022
cc16a9f
[stdlib] assign → update
glessard Nov 11, 2021
fcd10c3
[stdlib] partial buffer initialization (better buffer slices)
glessard Nov 30, 2021
831a87f
[stdlib] make additions non-abi
glessard Mar 9, 2022
00aaa07
[stdlib] improve doc-comments
glessard Mar 9, 2022
359e69d
[stdlib] make more additions non-abi
glessard Mar 9, 2022
75f64e7
[stdlib] implement slice operations without protocols
glessard Mar 10, 2022
9cbc9eb
[stlib] remove Slice<UMRBP>.copyMemory
glessard Mar 18, 2022
b0832cb
[abi] override the judgment of the abi stability test
glessard Jun 3, 2022
bb69e34
[test] initialization of slices of UnsafeBufferPointer types
glessard Mar 12, 2022
c78cc93
[gardening] typo fix
glessard Apr 19, 2022
6550fb1
[stdlib] add loading and storing to and from raw buffer slices
glessard Jun 1, 2022
254a8d4
[stdlib] fix inconsistency with storeBytes on slices
glessard Aug 15, 2022
d63747f
[stdlib] remove the single-element update functions
glessard Aug 16, 2022
d86b727
[test] add tests for `load` and `store` from slices
glessard Aug 15, 2022
26e5c43
[se-0370] update documentation to track proposal
glessard Aug 24, 2022
0a78756
[se-0370] add element labels to a returned tuple
glessard Aug 23, 2022
8ed1fc7
[abi] override the judgment of the abi stability test
glessard Aug 25, 2022
3e22d3a
[test] update to use the `fromContentsOf` argument label
glessard Aug 25, 2022
f5ffe09
[se-0370] fix editing errors
glessard Aug 24, 2022
c2c432c
[se-0370] re-implement in accordance with updated proposal
glessard Aug 30, 2022
d24b749
[se-0370] improve silgen names for renamed symbols
glessard Aug 30, 2022
285984e
[stdlib] simplify `update(fromContentsOf:)`
glessard Aug 31, 2022
aabf2e2
Update stdlib/public/core/UnsafeBufferPointer.swift.gyb
glessard Aug 31, 2022
99505d0
[stdlib] simplify `update(from:)`
glessard Aug 31, 2022
1f4ed8d
Update stdlib/public/core/UnsafePointer.swift
glessard Aug 31, 2022
805da6d
[stdlib] improve note about subscripts and initialization
glessard Aug 31, 2022
83c18de
Update validation-test/stdlib/UnsafeBufferPointerSlices.swift
glessard Sep 6, 2022
6512840
[stdlib] update `copyBytes` with primary associated type
glessard Sep 6, 2022
88225a2
[se-0370] some consistency tweaks
glessard Sep 6, 2022
44a349f
[se-0370] edit doc-comments for consistency
glessard Sep 6, 2022
d9a4488
[se-0370] use primary associated type
glessard Sep 7, 2022
559e5ed
[stdlib] use the internal precondition calls
glessard Sep 7, 2022
ffa7b0e
[se-0370] add notes regarding overlapping memory regions
glessard Sep 9, 2022
56c6887
[test] test overflow preconditions in collection copies
glessard Sep 10, 2022
71b6d99
[test] fix a test warning
glessard Sep 11, 2022
1152347
[stdlib] remove primary associated type from `copyBytes`
glessard Sep 12, 2022
dfda525
[abi] override the judgment of the abi stability test
glessard Sep 12, 2022
7f4caed
[stdlib] avoid primary associated type for the time being
glessard Sep 13, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions stdlib/public/core/ArrayBufferProtocol.swift
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ extension _ArrayBufferProtocol {
// so as not to self-clobber.
newTailStart.moveInitialize(from: oldTailStart, count: tailCount)

// Assign over the original subrange
// Update the original subrange
var i = newValues.startIndex
for j in subrange {
elements[j] = newValues[i]
Expand Down Expand Up @@ -199,17 +199,17 @@ extension _ArrayBufferProtocol {
let shrinkage = -growth
if tailCount > shrinkage { // If the tail length exceeds the shrinkage

// Assign over the rest of the replaced range with the first
// Update the rest of the replaced range with the first
// part of the tail.
newTailStart.moveAssign(from: oldTailStart, count: shrinkage)
newTailStart.moveUpdate(from: oldTailStart, count: shrinkage)

// Slide the rest of the tail back
oldTailStart.moveInitialize(
from: oldTailStart + shrinkage, count: tailCount - shrinkage)
}
else { // Tail fits within erased elements
// Assign over the start of the replaced range with the tail
newTailStart.moveAssign(from: oldTailStart, count: tailCount)
// Update the start of the replaced range with the tail
newTailStart.moveUpdate(from: oldTailStart, count: tailCount)

// Destroy elements remaining after the tail in subrange
(newTailStart + tailCount).deinitialize(
Expand Down
2 changes: 1 addition & 1 deletion stdlib/public/core/Bitset.swift
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ extension _UnsafeBitset {
@inlinable
@inline(__always)
internal func clear() {
words.assign(repeating: .empty, count: wordCount)
words.update(repeating: .empty, count: wordCount)
}
}

Expand Down
1 change: 1 addition & 0 deletions stdlib/public/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ set(SWIFTLIB_SOURCES
CommandLine.swift
SliceBuffer.swift
UnfoldSequence.swift
UnsafeBufferPointerSlice.swift
VarArgs.swift
Zip.swift
"${SWIFT_SOURCE_DIR}/stdlib/linker-support/magic-symbols-for-install-name.c"
Expand Down
1 change: 1 addition & 0 deletions stdlib/public/core/GroupInfo.json
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@
"UnsafePointer.swift",
"UnsafeRawPointer.swift",
"UnsafeBufferPointer.swift",
"UnsafeBufferPointerSlice.swift",
"UnsafeRawBufferPointer.swift"
],
"Protocols": [
Expand Down
4 changes: 2 additions & 2 deletions stdlib/public/core/HashTable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ extension _HashTable {
@_effects(releasenone)
internal func copyContents(of other: _HashTable) {
_internalInvariant(bucketCount == other.bucketCount)
self.words.assign(from: other.words, count: wordCount)
self.words.update(from: other.words, count: wordCount)
}

/// Insert a new entry with the specified hash value into the table.
Expand Down Expand Up @@ -446,7 +446,7 @@ extension _HashTable {
// without a special case.
words[0] = Word.allBits.subtracting(elementsBelow: bucketCount)
} else {
words.assign(repeating: .empty, count: wordCount)
words.update(repeating: .empty, count: wordCount)
}
}

Expand Down
2 changes: 1 addition & 1 deletion stdlib/public/core/StringGuts.swift
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ public func _persistCString(_ p: UnsafePointer<CChar>?) -> [CChar]? {
guard let s = p else { return nil }
let bytesToCopy = UTF8._nullCodeUnitOffset(in: s) + 1 // +1 for the terminating NUL
let result = [CChar](unsafeUninitializedCapacity: bytesToCopy) { buf, initedCount in
buf.baseAddress!.assign(from: s, count: bytesToCopy)
buf.baseAddress!.update(from: s, count: bytesToCopy)
initedCount = bytesToCopy
}
return result
Expand Down
Loading