| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
There was a problem hiding this comment.
LGTM
Sorry, something went wrong.
| // The change was made in https://github.com/dotnet/coreclr/pull/27229 | ||
| // The recommendation from .NET team is to not check for 'completed' if 'flush' is false. | ||
| // Break out of the loop if all bytes have been read. | ||
| if (!flush && bytesRead == byteIndex) |
There was a problem hiding this comment.
Now that complete is useless, I think we'd better change this implementation a bit more. Like the following:
while (true)
{
// Read at most the number of bytes that will fit in the input buffer. The
// return value is the actual number of bytes read, or zero if no bytes remain.
bytesRead = stream.Read(bytes, 0, useBufferSize * 4);
if (bytesRead == 0)
{
break;
}
bool completed = false;
int byteIndex = 0;
int bytesUsed;
int charsUsed;
while (bytesRead > byteIndex)
{
// If this is the last input data, flush the decoder's internal buffer and state.
bool flush = (bytesRead == 0);
decoder.Convert(bytes, byteIndex, bytesRead - byteIndex,
chars, 0, useBufferSize, flush,
out bytesUsed, out charsUsed, out completed);
// The conversion produced the number of characters indicated by charsUsed. Write that number
// of characters to our result buffer
result.Append(chars, 0, charsUsed);
// Increment byteIndex to the next block of bytes in the input buffer, if any, to convert.
byteIndex += bytesUsed;
}
} while (bytesRead != 0);
Sorry, something went wrong.
There was a problem hiding this comment.
Never mind. Change of the API makes it hard to reason about -- does decoder.Convert needs to be called again when bytesRead is 0? If it's needed, then will it produce any chars? If not, what's the purpose of doing so?
Without the understanding of those questions, let's keep the change as safe as possible, at least for now.
Sorry, something went wrong.
|
🎉v7.0.0-preview.6 has been released which incorporates this pull request.:tada: Handy links: |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
PR Summary
Move to .NET core 3.1-preview.2
PR Context
PR Checklist