vrruiz / xisfits

Convert images from XISF to FITS
MIT License
8 stars 0 forks source link

Added even more optimizations #19

Closed Razican closed 4 years ago

Razican commented 4 years ago

This is a follow-up from #18, that goes even further with the optimizations.

This makes the XISFData type much smaller, and it won't grow adding more types. This will also conform better to the XISF specification:

I referenced the spec documentation directly in the code where needed. Especifically, this conforms 100% with n-dimensional images and with the allowed sample formats. Note that UInt64, Complex32 and Complex64 won't work yet.

I also added an extra optimization in the u8_to_t!() conversion macro, that will pre-allocate the whole buffer from the beginning, instead of growing it on each new value. This can be done because we know the size of things before the execution.

When generating the FITS data, we have some extra optimizations:

Then, the data generation has also been optimized by using chunks_exact(), that should yield all chunks with the same size. Nevertheless, there is currently no check to ensure this always happens. If it doesn't, the input image wouldn't be spec conformant, and therefore the behaviour is for now undefined.

Still a ton of unwrap() in the code, that can be solved in the future by using error propagation.

vrruiz commented 4 years ago

I need to study to understand all changes, I'm still developing my Rust skills :D But they all seem really great. Thanks! :+1: