Skip to content

Add a "Fast Mod" Array Editor #1668

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 58 commits into
base: master
Choose a base branch
from

Conversation

bassmanitram
Copy link

@bassmanitram bassmanitram commented May 19, 2025

NOTE: Depends on PR #1667

This is essentially the standard Array editor with a tweak to the "Editor ID" that then allows it to NOT fully reset the value when simply modifying the order of the items in the array, making such reordering perform better, and to not experience degraded performance as the array grows in size.

The key "innovation" is to not tie the editor ID to its position in the array. Technically this would be possible with most of the functionality of the Array editor, even with the initial reliance on array index for the editor ID. However it is such a major change in semantics that I felt it better to implement the innovations via a subclass.

The major semantics change is, of course, that you cannot "construct" the path of an item editor based upon its position in the array. Instead you have to get the array editor, then index into the rows array, then obtain the path from the target row (or the editorId property of that row and append it to the path of the array editor).

Also, technically the cache SHOULD still work with a few tweaks - but for now I completely disable the cache.

As part of developing this subclass, the array editor itself was refactored quite a bit so that it didn't rely upon array position for so many of its operations where it didn't need to, even though it still does guarantee the tie between item index and item editor path, and to allow functionality to be overridden by subclasses. The cache, in particular, has been "objectified".

The bottom line, if you have a big array and you don't need to find item editors based upon their position in the array, then this subclass may afford you better performance when modifying the array, especially if such modifications are predominantly order changes.

Q A
Is bugfix?
New feature? ✔️
Is backward-compatible? ✔️
Tests pass? ✔️❌
Fixed issues
Updated README/docs? ✔️❌
Added CHANGELOG entry? ✔️❌

Martin Bartlett added 14 commits May 13, 2025 11:50
Main enhancements:
* Cleanup and alignment of Table and Array editor code
* New option `array_copy_in_place` determines whether a copied element is
  placed after the element it is copied from, or placed at the end of the array.
  For `array` the default value is `false` corresponding to the existing behaviour.
  For `table` the default value is `true` corresponding to the existing behaviour.
Rather than the potentially expensive validation of a value
against multiple schemata, how about we provide the path to
a value field that tells you the type and an array of values in
the order of declaration!
This change removes the data-index item, and instead discovers the index of the currently active tab - this allows
the tabs to be moved without refreshing the value - making
move, copy-in-place and drop WAY faster (not here but in
a subclass)

Also a fix to the hard-usage of the index in the editor path.
As before, instead of using the row index we use the 'editorId' set by the class/subclass. (in array.js that IS the
index, but in a subclass that, say, forgoes the use of the cache and, instead, uses editor paths NOT tied to the array
item order, the implementation of move, delete, copy, add, and drop can all be vastly improved, and in a way that does not degrade with the increasing size of the array).
The tiny increase in resources is justified in order to allow
subclasses to use a different strategy for row order management
(See FastModArrayEditor)
@bassmanitram bassmanitram changed the title Adda a "Fast Mod" Array Editor Add a "Fast Mod" Array Editor May 19, 2025
Martin Bartlett added 15 commits May 19, 2025 11:58
All button event listeners now call an instance method for the
main implementation, allowing subclasses to implement different
strategies (e.g. see FastModArray). Those event listener MAY
choose to return a value that indicates to the event listener that
the remaining functionality of the listener should be executed.

Mostly that's specifically returning `true` - which is backward
compatible to the original array semantics. For one case, where an
object is expected, _not_ rturning that object has the same effect.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant