-
-
Notifications
You must be signed in to change notification settings - Fork 21.7k
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
C#: Remove VariantSpanDisposer and use constants in stackalloc #69194
C#: Remove VariantSpanDisposer and use constants in stackalloc #69194
Conversation
Span<IntPtr> argsSpan = argc <= VarArgsSpanThreshold ? | ||
stackalloc IntPtr[VarArgsSpanThreshold] : |
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.
The VarArgsSpanThreshold
constant has a value of 5
in Callable
, but 10
in code generated by bindings_generator. Not sure why they are different and maybe we should consider declaring this constant in a single place and reuse it rather than redefine it in every file.
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's weird that I added VarArgsSpanThreshold
here but used a hard-coded value instead. It's obviously a mistake, but I don't know which one I truly wanted. I think 10
should be fine for both.
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'll change it to 10
in this PR and we can move the constant to a single place later.
This also fixes #68590 where custom resources with an array of variants would prevent reloading of the c# assemblies. |
a10f536
to
1343934
Compare
- Remove `VariantSpanDisposer`, no need to dispose of the Variant Spans since we are now borrowing the Variants instead of copying them. - Remove `VariantSpanExtensions.Cleared` that was only used so the Span was initialized for `VariantSpanDisposer` to know what to dispose. - Fix stackalloc Spans to use constant VarArgsSpanThreshold and avoid bound checks.
1343934
to
3ff1810
Compare
Thanks! |
VariantSpanDisposer
, no need to dispose of the Variant Spans since we are now borrowing the Variants them instead of copying them.May fix: