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

Changed the BufferedBinaryReader to using pooled arrays #11

Merged
merged 2 commits into from
Mar 10, 2024

Conversation

ArnimSchinz
Copy link
Contributor

Instead of allocating a new buffer on every file, one can (re)use pooled arrays. There is a good Shared ArrayPool implementation inside System.Buffers, which can be used for this purpose. There should not be a memory-leak in case the buffer is not returned to the pool, so the Dispose() method is enough and no destructor is needed. The array returned by the pool could be larger than the requested size, since the size will always be a power of 2. This is why the buffersize is derived from the length of the returned array. This change only affects 4 lines, I don't know why it shows such a large difference.

@nmangue nmangue merged commit e2c630e into nmangue:master Mar 10, 2024
@nmangue
Copy link
Owner

nmangue commented Mar 10, 2024

Hello Arnim ! Thank you for your contribution

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

Successfully merging this pull request may close these issues.

None yet

2 participants