-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Memorify DeflateManagedStream #47389
Conversation
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. |
Area label should be |
…y-DeflateManagedStream
...aries/System.IO.Compression/src/System/IO/Compression/DeflateManaged/DeflateManagedStream.cs
Show resolved
Hide resolved
@@ -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. |
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.
This is all dead code. _formatReader is always going to be null.
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.
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.
I'm closing this for now. I'll redo it once 47408 has merged to avoid merge conflicts, and because my implementation broke CI. |
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.