-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Use simple array for AggregateException inner exceptions storage #44787
Conversation
I couldn't figure out the best area label to add to this PR. If you have write-permissions please help me learn by adding exactly one area label. |
src/libraries/System.Private.CoreLib/src/System/AggregateException.cs
Outdated
Show resolved
Hide resolved
// because we're going to put them into a ReadOnlyCollection which simply reuses | ||
// the list passed in to it. We don't want callers subsequently mutating. | ||
Exception[] exceptionsCopy = new Exception[innerExceptions.Count]; | ||
_innerExceptions = cloneExceptions ? new Exception[innerExceptions.Length] : innerExceptions; |
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.
(Exception[])innerExceptions.Clone()
?
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.
Is it better with the cast from object?
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.
Sorry, not sure what you mean by that question.
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.
I meant is Clone version better if it has to generate a cast check?
What is the purpose of this change? |
@stephentoub remove the unnecessary wrapping and ROS dependency and interfaces casts. |
But it still uses ROC:
What am i missing? |
It's used from a single property now which is rarely used (and could be avoided if needed). The linker will be able to remove the field by default whereas before it was a dependency from ctor which made it essentially non-trimmable. |
Not really. Most code paths that explicitly catch AggregateException then use InnerExceptions. And even this PR is insufficient I'd expect to be able to ever trim it from corelib, since Task itself relies on InnerExceptions in a way that's unlikely to be trimmable. If the goal is to enable ROC to be trimmable in most apps, let's make sure this PR actually does that. |
This didn't show up for wasm but I fixed the calls anyway to make this change more effective. |
src/libraries/System.Private.CoreLib/src/System/AggregateException.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Private.CoreLib/src/System/AggregateException.cs
Outdated
Show resolved
Hide resolved
…tion.cs Co-authored-by: Stephen Toub <[email protected]>
to drop unnecessary wrapping into ReadOnlyCollection. The change also simplified ctor chaining to avoid extra wrapping/casts where it's not needed.