cmpute / dashu

A library set of arbitrary precision numbers implemented in Rust.
Apache License 2.0
74 stars 9 forks source link

Refactor `Memory` to reduce unsafe code #39

Open eduardosm opened 9 months ago

eduardosm commented 9 months ago

Refactor Memory to avoid dealing with manual allocations, raw pointers and memory layouts.

Now it uses a Vec (with length zero and desired capacity) and Vec::spare_capacity_mut to access the allocated capacity.

cmpute commented 9 months ago

Thanks for the PR! What necessitates this change in your opinion? I think the original author of the memory allocation utilities (i.e tczajka) keeps this design because it will be easier to create customized allocation logics in future.

eduardosm commented 9 months ago

Since it was only used to allocate slices of Word, I simplified it accordingly. Is there a need to allocate arbitrary layouts?

cmpute commented 7 months ago

This change might be related to #43 , lets wait for that issue to have a rough idea of how to improve this.