-
Notifications
You must be signed in to change notification settings - Fork 32
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
Optimize ArrayBuffer BytesFromStream #38
Conversation
When stream.Length <= int.MaxValue, the stream can just be read in one go into a byte[], instead of going through MemoryStream.ToArray(). This reduces the number of byte[] allocations when initializing.
Thanks for the PR! It looks like the tests are failing. Also, please update the tests to ensure both the new code path and the old code path are tested. |
Broken test has been fixed. Right now, the new code path will always be used. Does MaxMind have any test databases that are larger than int.MaxValue (2,147,483,647 bytes / ~2 GB) to use in a test for the original code path? |
Couldn't we test the old code path by using a stream that doesn't support seeking? Maybe a |
That could make sense, will see if I can add that. |
Added a test for it. |
Thanks! |
Optimize ArrayBuffer BytesFromStream
When stream.Length <= int.MaxValue, the stream can just be read in one
go into a byte[], instead of going through MemoryStream.ToArray(). This
reduces the number of byte[] allocations when initializing.