atree
atree copied to clipboard
Add `Array.Swap()` to swap two elements in place
Updates https://github.com/onflow/cadence/pull/2626
Issue To Be Solved
Currently, there is no Atree function to swap two elements of an Array, so Cadence needs to do a remove and insert which can be inefficient.
Thanks @bluesign for bringing this up at https://github.com/onflow/cadence/pull/2626! :+1:
Suggested Solution
Add Array.Swap() to swap two elements in place.
@fxamacker How much work would it be to add such a function?
@fxamacker How much work would it be to add such a function?
@turbolent About 2-3 uninterrupted person-days to add function and tests.
@turbolent Is this feature still needed?
I can re-estimate work required because of changes in atree v0.8.0 (e.g. atree inlining & deduplication, etc.).