Fix Inefficient Cloning in From<BigDecimal> for MmNumber #2338
Labels
improvement: resource usage
Improvements made on resource usage on runtime or/and compile time
priority: Backlog
Tasks not yet scheduled or lower priority.
The current implementation of From for MmNumber unnecessarily takes ownership of BigDecimal, but then immediately borrows it with from_dec_to_ratio(&n), making the move redundant. Since the function only needs a reference, we should implement From<&BigDecimal> to allow efficient conversion without cloning.
see #2112 (comment) - we clone BigDecimal amount in so many places.
komodo-defi-framework/mm2src/mm2_number/src/mm_number.rs
Lines 102 to 104 in ff0eefc
Rust allows implementing both
From<BigDecimal>
andFrom<&BigDecimal>
, we can support both ownership-based and reference-based conversions.The text was updated successfully, but these errors were encountered: