Skip to content
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

Header-aware visitor should not immediately allocate arrays sized to the limits. #17

Closed
airbreather opened this issue Jul 18, 2019 · 1 comment
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@airbreather
Copy link
Owner

_headersBuilder = ImmutableArray.CreateBuilder<string>(maxHeaderCount);
_headerBuffer = new char[maxHeaderLength];

These immediately allocate arrays that are as big as the maximum limits requested by the caller.

The caller should be able to ask us to essentially turn off enforcement of these limits by setting the value absurdly high, without having to pay the worst-case cost every single time.

@airbreather airbreather added the enhancement New feature or request label Jul 18, 2019
@airbreather airbreather added this to the 1.2.0 milestone Jul 18, 2019
@airbreather airbreather self-assigned this Jul 18, 2019
@airbreather
Copy link
Owner Author

We should still require val <= 0x7FEFFFFF, since bigger is completely absurd, and at least these two mainstream implementations of .NET Standard 2.0 are essentially guaranteed to fail past that point anyway, so it seems to make more sense to fail early in testing instead of when it happens in production:

CoreCLR:
https://github.com/dotnet/coreclr/blob/1d47f41f3d3d1e391818323df4378e82b95292f8/src/System.Private.CoreLib/shared/System/Array.cs#L20-L25

Classic:
https://github.com/microsoft/referencesource/blob/e0bf122d0e52a42688b92bb4be2cfd66ca3c2f07/mscorlib/system/array.cs#L619-L624

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant