Skip to content

add smart_replace method for MutableVec and MutableBTreeMap for avoiding spurious .replaces #5

@databasedav

Description

@databasedav

if the source of a signal vec/map always emits the entire collection, then using .replace will overwrite every element even if some are unchanged, which is akin to immediate mode if it's called every frame

instead, using https://github.com/mitsuhiko/similar (or something else?) for vecs and a naive iter (is there something better?) for maps, produce a sequence of non-::Replace diffs which can then be applied to the target MutableVec or MutableBTreeMap

the API should look something like this

fn smart_replace(self: &mut MutableVec, algorithm: similar::Algorithm, replace: &[T]);

fn smart_replace(self: &mut MutableBTreeMap, replace: &[K, V]);

this should be feature gated for vecs since we're pulling in a diffing dependency but be included by default

open to bikeshedding on the function name, maybe something like diff_replace instead ?

spurred by https://discord.com/channels/691052431525675048/1399619915295490141/1399753665996132436

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions