-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[stdlib]remove _PointerFunction #17809
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
Conversation
@swift-ci please test |
@swift-ci please smoke benchmark |
Build failed |
Build comment file:Optimized (O)Regression (19)
Improvement (33)
No Changes (406)
Hardware Overview
|
@swift-ci please benchmark |
@swift-ci please test linux platform |
Running full benchmark, some of those regressions are notoriously noisy but you never know. |
Build failed |
Hmm ok that's a genuine linux failure rather than the spurious one this time. |
Build comment file:Optimized (O)Regression (10)
Improvement (13)
No Changes (435)
Unoptimized (Onone)Regression (8)
Improvement (51)
No Changes (399)
Hardware Overview
|
@swift-ci please test |
Build failed |
Build failed |
@swift-ci please smoke benchmark |
1 similar comment
@swift-ci please smoke benchmark |
Build comment file:Optimized (O)Regression (24)
Improvement (19)
No Changes (415)
Hardware Overview
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
This all seems reasonable to me, but then I didn't even know this existed =) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 Closures can still be slower sometimes than protocols with a single function requirement (see ObserverClosure vs ObserverForwardingStruct benchmarks), but _PointerFunction seems way over the top
stdlib/public/core/ArrayShared.swift
Outdated
|
||
_sanityCheck(headCount >= 0) | ||
_sanityCheck(newCount >= 0) | ||
|
||
let initializeNewElements = initializeNewElements ?? { ptr, count in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if the closure parameter was non-optional, with this as the default value?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It makes the function signature pretty gnarly but maybe it's worth it?
_ dest: inout _ContiguousArrayBuffer<Element>, | ||
_ headCount: Int, // Count of initial source elements to copy/move | ||
_ newCount: Int, // Number of new elements to insert | ||
_ initializeNewElements: Initializer | ||
) where | ||
Initializer: _PointerFunction, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Idea for an alternative design: replace the closure parameter by returning the newly opened uninitialized gap as an UnsafeMutableBufferPointer
, which the callee would be expected to fill in.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting idea! I think I lean more towards keeping the closure, I like scoping the pointer mutation to as small a scope as possible.
@swift-ci please test |
Build failed |
Build failed |
The _PointerFunction protocol and related types are kind of weird and unnecessary.