Skip to content
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

[stdlib] Add arg labels to _expectEnd #5485

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions stdlib/public/core/ArrayBufferProtocol.swift
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ extension _ArrayBufferProtocol where Index == Int {
(elements + j).initialize(to: newValues[i])
newValues.formIndex(after: &i)
}
_expectEnd(i, newValues)
_expectEnd(of: newValues, is: i)
}
else { // We're not growing the buffer
// Assign all the new elements into the start of the subRange
Expand All @@ -178,7 +178,7 @@ extension _ArrayBufferProtocol where Index == Int {
formIndex(after: &i)
newValues.formIndex(after: &j)
}
_expectEnd(j, newValues)
_expectEnd(of: newValues, is: j)

// If the size didn't change, we're done.
if growth == 0 {
Expand Down
5 changes: 2 additions & 3 deletions stdlib/public/core/Arrays.swift.gyb
Original file line number Diff line number Diff line change
Expand Up @@ -1656,7 +1656,7 @@ internal struct _InitializeMemoryFromCollection<
newValues.formIndex(after: &q)
p += 1
}
_expectEnd(q, newValues)
_expectEnd(of: newValues, is: q)
}

init(_ newValues: C) {
Expand Down Expand Up @@ -1694,8 +1694,7 @@ internal func _arrayOutOfPlaceReplace<B, C>(
/// A _debugPrecondition check that `i` has exactly reached the end of
/// `s`. This test is never used to ensure memory safety; that is
/// always guaranteed by measuring `s` once and re-using that value.
// FIXME(ABI)#15 : add argument labels.
internal func _expectEnd<C : Collection>(_ i: C.Index, _ s: C) {
internal func _expectEnd<C : Collection>(of s: C, is i: C.Index) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extension Collection {
   internal func _expectEnd(at: Self.Index) { ... }
}

maybe?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought about doing that, but it didn't sit right with me. assert-like things seem to feel a bit better as stand-alone functions than methods. Not sure I'm being rational about that tho.

_debugPrecondition(
i == s.endIndex,
"invalid Collection: count differed in successive traversals")
Expand Down
2 changes: 1 addition & 1 deletion stdlib/public/core/Collection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1281,7 +1281,7 @@ extension Collection {
formIndex(after: &i)
}

_expectEnd(i, self)
_expectEnd(of: self, is: i)
return Array(result)
}

Expand Down
2 changes: 1 addition & 1 deletion stdlib/public/core/ContiguousArrayBuffer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,7 @@ internal func _copyCollectionToContiguousArray<
source.formIndex(after: &i)
p += 1
}
_expectEnd(i, source)
_expectEnd(of: source, is: i)
return ContiguousArray(_buffer: result)
}

Expand Down