lui icon indicating copy to clipboard operation
lui copied to clipboard

Smarter reordering algorithm

Open L3P3 opened this issue 4 years ago • 1 comments

IS

~~Currently, node_map items are ordered by reinserting them when their index (absolute position) has changed.~~ ~~Currently, node_map items are ordered by reinserting all of them.~~ Currently, node_map items are ordered by reinserting all of them if their nextSibling changes.

SHOULD

~~Just reinsert them if their relative position has changed!~~ Try to reinsert as fewest as possible without getting too complicated.

Note

In practice, it works well enough. But as shown by benchmark, this makes lui one of the slowest candidates for "remove row", since all n rows get reinserted without any need. It just looks bad in the table!

L3P3 avatar Aug 01 '21 22:08 L3P3

The index-based method was pretty stable in most cases but in some rare cases, the reordering would have been incorrect, so I went for a temporary and much less efficient solution: Reinserting all items on each rerender.

L3P3 avatar Aug 29 '21 12:08 L3P3