-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
CodeGenerator.EmitStackAlloc - Avoid capturing blob array #76660
Conversation
@@ -45,7 +45,11 @@ private void EmitStackAlloc(TypeSymbol type, BoundArrayInitialization? inits, Bo | |||
var sizeInBytes = elementType.EnumUnderlyingTypeOrSelf().SpecialType.SizeInBytes(); | |||
|
|||
ImmutableArray<byte> data = GetRawData(initExprs); | |||
#if NET8_0_OR_GREATER | |||
if (!data.AsSpan().ContainsAnyExcept(data[0])) |
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.
We don't generally have a problem with conditional code, but we usually want to have a good reason to have it; do you have benchmarks or other data indicating this capture is a problem?
@@ -45,7 +45,11 @@ private void EmitStackAlloc(TypeSymbol type, BoundArrayInitialization? inits, Bo | |||
var sizeInBytes = elementType.EnumUnderlyingTypeOrSelf().SpecialType.SizeInBytes(); | |||
|
|||
ImmutableArray<byte> data = GetRawData(initExprs); | |||
#if NET8_0_OR_GREATER | |||
if (!data.AsSpan().ContainsAnyExcept(data[0])) |
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.
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.
In fact we already have the overload in ImmutableArrayExtensions:
public static bool All<T, TArg>(this ImmutableArray<T> array, Func<T, TArg, bool> predicate, TArg arg)
Done with review pass (commit 1) |
src/Compilers/CSharp/Portable/CodeGen/EmitStackAllocInitializer.cs
Outdated
Show resolved
Hide resolved
…r.cs Co-authored-by: Jan Jones <[email protected]>
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 (commit 3)
@alrz Thanks for the contribution |
* upstream/main: (368 commits) Cleanup tests Add test Add test Add test Fix issue parsing regex category Properly simplify pattern when converting to pattern matching update publishdata after VS 17.13 snap Simplify Docs Do not lift type parameters in extract method declared within the selected region Fix ExtractMethod in VB elseif blocks Rework our Helix Process (dotnet#76703) Stash and restore original culture in CultureNormalizer (dotnet#76713) PR comments Adding checks for mutable structs. Add additional tests for string escape sequences CodeGenerator.EmitStackAlloc - Avoid capturing blob array (dotnet#76660) Update comments and exception type for LSP stdio configuration based on review feedback Fix race generating Microsoft.Managed.Core.CurrentVersions.targets (dotnet#76701) Update FileDownloader.cs ...
I'm not sure if conditional code on dotnet version is acceptable as this API is only available in 8.0+.