-
Notifications
You must be signed in to change notification settings - Fork 6.1k
Closed
Description
See Twitter discussion here: https://twitter.com/EgorBo/status/1508069816275513344
tldr:
Current:
const int MaxStackLimit = 1024;
Span<byte> buffer = inputLength <= MaxStackLimit ? stackalloc byte[inputLength] : new byte[inputLength];Slightly faster:
const int MaxStackLimit = 1024;
Span<byte> buffer = inputLength <= MaxStackLimit ? stackalloc byte[MaxStackLimit].Slice(0, inputLength) : new byte[inputLength];Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
- ID: ecde487e-96e5-85c2-ff87-227994f705ad
- Version Independent ID: f77588b3-9b31-f8ce-fad5-bf937337eb8c
- Content: stackalloc expression - C# reference
- Content Source: docs/csharp/language-reference/operators/stackalloc.md
- Product: dotnet-csharp
- Technology: csharp-language-reference
- GitHub Login: @BillWagner
- Microsoft Alias: wiwagn