Closed Byron closed 2 years ago
Here is how the altered method can be used.
Thanks, this is great. I don't think it needs to be an optional feature, though. You can use core::mem::replace
in no_std
crates. Also, changing the signature of a function when a feature is enabled could technically break other crates in the same dependency graph that depend on the type of the function.
I'll merge this PR, and then push a follow-up to make it always use the new method.
Absolutely awesome, thank you!
Also thanks for removing the feature toggle, there is so much I don't know about no-std
, but I will get there (probably when gitoxide
goes WASM :) ).
I added this to be able to avoid allocations if the entry is allocating, In case of
gitoxide
this saves a couple of millions of allocations in favour of a few thousand re-allocs.Performance wasn't measurably better in my case, just as if the allocator can already repurpose previously freed slabs of memory pretty well or at only a very low cost.
Since it doesn't seem to hurt providing this capability, I am creating this PR anyway in the hopes it does indeed make sense to some in this form or another.
Please let me know :).