-
Notifications
You must be signed in to change notification settings - Fork 34
Cleanup code and improve reliability. #38
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
Conversation
It can be entirely replaced by built-in APIs that are available on all targeted frameworks.
The classes' implementation became simpler, safer, and less error-prone.
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.
Left some additional comments.
|
Oh you wrote One advantage to targeting less frameworks is reduced package size; right now it is in 1.15MB, which is not yet but close to what I would call "big". But it's not the end of the world. All feedback was addressed, and I also fixed a memory leak I spotted. I am going to run some benchmarks and will get back to you. |
The results are in. Before
After
I am noticing a slight improvement for .NET 7 and 8, and either no change or a slight regression for some earlier frameworks. What do you think? |
I'll run benchmarks later too. I also need to check that a .NET Native project builds with |
My results: Before
After
Benchmarks LGTM. |
@teo-tsirpanis Thank you! |
This PR:
InlineIL
package. All its uses can be replaced by theSystem.Runtime.CompilerServices.Unsafe
package or other built-in .NET APIs, and the replaced code is simpler.Compressor
andDecompressor
classes to use classes derived fromSafeHandle
to manage the ZSTD context pointers. While safe handles are usually used for interop with native code, we use them here in managed code to manage the lifetime of manually allocated memory. This makes the code simpler and much more reliable; you don't have to writeGC.KeepAlive
s anymore, and safe handles protect from cases like one thread callingDispose
while another thread uses the resource.null
. This is not valid code since spans are structs and not classes.