atree icon indicating copy to clipboard operation
atree copied to clipboard

Add `Array.Swap()` to swap two elements in place

Open fxamacker opened this issue 2 years ago • 3 comments

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 avatar Jul 11 '23 18:07 fxamacker

@fxamacker How much work would it be to add such a function?

turbolent avatar Jul 31 '23 18:07 turbolent

@fxamacker How much work would it be to add such a function?

@turbolent About 2-3 uninterrupted person-days to add function and tests.

fxamacker avatar Aug 02 '23 15:08 fxamacker

@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.).

fxamacker avatar Sep 05 '24 14:09 fxamacker