3 ms·
The person you are replying to is talking about things like maps implemented with persistent trees. Updating a value in such a map generally only involves copyi
by moon_priestess 10y ago
The person you are replying to is talking about things like maps implemented with persistent trees. Updating a value in such a map generally only involves copying O(log N) nodes in the tree: It's not necessary to shallow copy the entire tree itself.
- Illniyar 10y agoAnd immutable.jsdoes that?
- undershirt 10y agoOops, didn't realize that seamless does its own shallow copying strategy with `merge`, `set`, `setIn`. I can't speak to how this compares to persistent data structures implemented by immutable.js, clojure, elm, etc. But it looks like the seamless author said the following about it: > Persistent data structures are different, as their performance improvements are passive. Although seamless-immutable does not (and cannot, while maintaining its backwards compatibility with vanilla JS collections) use things like VLists under the hood, its cloning functions—such as merge—only bother to make shallow copies, as shallow and deep copies of immutable values are equivalent. In practice, this simple passive optimization has been sufficient; we have yet to encounter a performance problem that Bagwell-style persistent data structures would have solved. from: http://tech.noredink.com/post/107617838018/switching-from-immutablejs-to-seamless-immutable#performance http://tech.noredink.com/post/107617838018/switching-from-im...