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

Memorify DeflateManagedStream #47389

Conversation

NewellClark
Copy link
Contributor

This is one of the violations found by this prototype analyzer.

Unfortunately, one path of execution calls into IFileFormatReader, which does not support Span and Memory. I did the same thing that I did with my CryptoStream PR and check if the memory is an array, and simply do the copy if it is.

Unlike with CryptoStream, however, IFileFormatReader is an internal interface, so we may be able to change it down the road. Might be something worth considering. I can create an issue for that if it's deemed worthwhile.

@dotnet-issue-labeler
Copy link

I couldn't figure out the best area label to add to this PR. If you have write-permissions please help me learn by adding exactly one area label.

@NewellClark
Copy link
Contributor Author

Area label should be System.IO.Compression

@NewellClark NewellClark marked this pull request as draft January 25, 2021 08:46
@@ -140,16 +142,27 @@ public int Inflate(byte[] bytes, int offset, int length)
if (_hasFormatReader)
{
Debug.Assert(_formatReader != null);
_formatReader.UpdateWithBytesRead(bytes, offset, copied);
// Skip the copy if bytes is actually an array.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is all dead code. _formatReader is always going to be null.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's awesome! I think what I'm going to do is wait until #47408 is merged, and then I'll redo this pull-request. That way we'll avoid merge conflicts.

@NewellClark
Copy link
Contributor Author

I'm closing this for now. I'll redo it once 47408 has merged to avoid merge conflicts, and because my implementation broke CI.

@ghost ghost locked as resolved and limited conversation to collaborators Feb 24, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants