Removed unnecessary string conversions, using binary forms of special addresses for direct bit comparisons to cut conversion costs and speed up comparisons.
Reduced repeated calls by introducing local variables to cache results, minimizing multiple calculations of the same expression, thus boosting performance.
Simplified code expressions for easier readability and maintenance.
Wrote unit tests to ensure consistent function behavior before and after optimization.
Example 1
Before: Checks quoteToken as string, converts common.XDCNativeAddress hex to address
After: Direct bit comparison is used, and the result of tx.To() is stored in a variable for reuse, leading to a more streamlined and easily comprehensible code structure.
Proposed changes
Example 1
quoteToken
as string, convertscommon.XDCNativeAddress
hex to addresscommon.XDCNativeAddressBinary
by binary form, fetches price without conversion.Example 2
token
string equality withcommon.XDCNativeAddress
and log with string conversions.token
known asXDCNativeAddress
, use its string type directly.Example 3
To()
function to retrieve the same result in the logic.tx.To()
is stored in a variable for reuse, leading to a more streamlined and easily comprehensible code structure.Types of changes
What types of changes does your code introduce to XDC network? Put an
✅
in the boxes that applyImpacted Components
Which part of the codebase this PR will touch base on,
Put an
✅
in the boxes that applyChecklist
Put an
✅
in the boxes once you have confirmed below actions (or provide reasons on not doing so) that