Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Small follow up on #846. This PR suggest to change two things:
First, it introduces a
handle_cbor
function that handles the cbor de(serialization) and error handling. I verified in 032de2d that the function generalizes well (in that commit I used it to take arguments to thepath-utils.bounds
. 032de2d passes all the tests too, but needs a bigger rewrite to get good speed, so I'll do that in another PR).The
handle_cbor
function might look complex, but essentially what it is is a parametric function over types T (the arguments structCubicExtremaArgs
), F (the processor functioncubic_extrema
), and U (the return type of F, so the return type ofcubic_extrema
). Since it is a parametric function, all these types will be inferred during the Rust compilation. The compiler will create one function for each combination of these types that is used in the code. So this parametric function should not affect CeTZ runtime since it's all compiled into the wasm binary.Second, I got rid of
vector_add
andvector_scale
in order to improve performance. Long-term we should probably get these functions from a library as you mentioned, but for now it was faster to avoid the intermediate vectors. This change is a few percent faster.One small note on the arguments of
cubic_point
. I used pointers now for thePoint
. This is a tiny bit faster than cloning thePoint
vector. All in all it didn't seem to matter much though. The vectors are so small that cloning is roughly as fast as passing pointers. At least in this case.