On Thu, May 7, 2020 at 2:27 PM vitalije <[email protected]> wrote:

QTreeWidgetItem class has a clone method which runs quite fast.
>

Wow.  I didn't know that. Sounds like a great fit for the new code.

> Cloning entire tree using this method is not problem at all. The problem
> is that if a script changes vnodes we need to synchronize them after script
> has finished. This synchronization can drop some items that are required
> for undoing earlier operations. To avoid this Leo should add to the undo
> list a new step which contains the copy of the tree items before executing
> script. All these operations are pretty cheap. The time will be spent in
> the redrawing tree from scratch after the script execution.
>

I like the simplicity of this scheme. I'm a bit worried about memory.

In Leo's present undo scheme no data are ever reclaimed because references
are never deleted. Leo's present undo scheme minimizes the per-operation
memory requirements as much as possible. I worry about creating O(N) data
items on every undo operations, where N is the *total* number of tree nodes.

As I write this I've just realize that it would be possible to use diffing
> algorithm to update tree after the script. The only thing that is necessary
> is to make execute script undoable. Updating the tree using the diff
> algorithm will have exactly the same tree items as they were before the
> script. Nothing would be lost. All changes that must be made can be easily
> recorded in the undo bead for later undo/redo. This has a chance to make
> things a lot faster.
>

Imo, the big factor concerning speed is python's GC. Could the diff scheme
reduce the per-operation cost from O(N) to O(1)?

Edward

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/leo-editor/CAMF8tS03U2TZr%2BheG4iN5KpF9k_ya5T3B12dXiaTEhUx7OrxfQ%40mail.gmail.com.

Reply via email to