-
Notifications
You must be signed in to change notification settings - Fork 116
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 ReadOnlySpan instead of Array for argument #136
Comments
Hi @arontsang! The issue with attribute objects - they are not immutable. Otherwise I'd gladly have a prepopulated any readonly collection for them. What do you think? |
Hi Pamidur, I mean for
The line Not sure how much of an impact it adds. But if that was replaced with a On hot path code, this could make a noticeable difference to performance. There would of course be the following downsides:
An alternative to using |
Come to think about it. You can still stackalloc your |
I was thinking about it. What if we preallocate object[] on the heap and then reuse it? This way:
|
|
agree to both. I do think ReadOnlySpan makes a lot of sense. It could be probably an option for user to decide which API to use. And it will simplify things around references if user already references System.Memory. For In future I also plan to introduce possibility to have generic Around method with signature wdyt? |
For your "around<T>", nothing stops the user from trampolining from a
synchronous function that returns a Task to an async function. The only
"step" they need to take before take off, would be to call
ReadOnlySpan<object>.ToArray(), which explicitly allocates stack array
(which is unavoidable with Task).
…On Sun, 11 Oct 2020, 22:23 Oleksandr Hulyi, ***@***.***> wrote:
agree to both. I do think ReadOnlySpan makes a lot of sense. It could be
probably an option for user to decide which API to use. And it will
simplify things around references if user already references System.Memory.
This being said I can see the following feature description:
For ```Source.Arguments`` advice argument user should be able to choose
either use object[] of ReadOnlySpan[]. Weaver produces appropriate code
base on the user decision.
In future I also plan to introduce possibility to have generic Around
method with signature public T Around<T> where T is target method return
type, which could possibly enable user to make async Task advices, thus I
see it is required to explicitly forbid advices to be async.
wdyt?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#136 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AA46MLKCIFE6DJPNOHD3BIDSKG5XHANCNFSM4RXJGOGQ>
.
|
This would reduce the heap allocation per injection, which would help with performance.
The text was updated successfully, but these errors were encountered: