dont mutate maps or mirror #28
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "mapping-immutable-maps-mirror-arrays"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Was reverting tracked changes and noticed that
appendMapmutates the original array passed intonew Mapping. Doesn't happen in the example code but happened in my codebase where I didn't defensively clone the maps array.I don't think this is a good idea. It will make building up bigger maps with
appendMaptake quadratic time, and generally introduce a lot of unnecessary copies. Does attached patch look like a reasonable solution?Yep, copying the original array once when
appendMapis called for the first time works too.Pull request closed