-
Notifications
You must be signed in to change notification settings - Fork 352
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
Use the array pool in Json writer #1420
Conversation
@ysanghi Would you please also take a look this PR? thanks. |
@@ -23,12 +23,23 @@ internal static class BufferUtils | |||
/// <returns>The initialized buffer</returns> | |||
public static char[] InitializeBufferIfRequired(char[] buffer) | |||
{ | |||
if (buffer == null) | |||
return InitializeBufferIfRequired(null, buffer); |
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.
Why do we need this method? can't we do something like this?
if (buffer == null) {
return RentFromBuffer(null, buffer);
}
return buffer;
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 avoiding a duplicated code. At later, if we change something, we only change the second method, don't need to change all methods. Thanks.
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.
@@ -392,6 +398,7 @@ public void WriteRawValue(string rawValue) | |||
/// </summary> | |||
public void Flush() | |||
{ | |||
BufferUtils.ReturnToBuffer(this.ArrayPool, this.buffer); | |||
this.writer.Flush(); |
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.
Should we return to pool on Flush or Dispose? #Closed
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.
@mikepizzo I changed to use the "Dispose". #Closed
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.
Issues
Description
Checklist (Uncheck if it is not completed)
Additional work necessary
If documentation update is needed, please add "Docs Needed" label to the issue and provide details about the required document change in the issue.