ENB: About the new icon drawing code

35 views
Skip to first unread message

Edward K. Ream

unread,
Sep 4, 2022, 12:11:04 PM9/4/22
to leo-editor
This Engineering Notebook post discusses the aftermath of PR #2803, containing a huge speedup in qtree.redraw_after_icons_changed.

tl;dr: redraw_after_icons_changed is a faux helper!

Background

The old code (qtree.redraw_after_icons_changed) updated all visible nodes in the entire tree, a huge waste of time. Instead, the new code updates only c.p and its direct parents.

However, the new code is dubious, because p.setAllAncestorAtFileNodesDirty is complicated. It can "dirty" nodes far outside of c.p's ancestors or descendants.

Aha: updating icons is easier without a helper

The new version of qtree.redraw_after_icons_changed just calls qtree.updateIcon(p) for a few positions. But there are two Ahas:

Aha 1: Calling updateIcon(p) would be easy to do anywhere!
Aha 2: qtree.redraw_after_icons_changed can't know which positions to update!

In short: redraw_after_icons_changed is a faux helper.

Summary

There is no need for AI in a faux helper. Leo's core code will call c.updateIcon(p) directly. Finding that code is easy: just look calls for the faux helper!

I'll soon retire all x.redraw_after_icons_changed methods.

Edward

Edward K. Ream

unread,
Sep 4, 2022, 6:04:30 PM9/4/22
to leo-editor
On Sunday, September 4, 2022 at 11:11:04 AM UTC-5 Edward K. Ream wrote:

Summary

There is no need for AI in a faux helper. Leo's core code will call c.updateIcon(p) directly. Finding that code is easy: just look calls for the faux helper!

Research reveals that this plan would be difficult to get right.

Happily, there a simpler way will probably work: have the VNode methods that affect icons call v.updateIcon() directly! We'll see...

Edward

Edward K. Ream

unread,
Sep 5, 2022, 8:55:00 AM9/5/22
to leo-editor
On Sunday, September 4, 2022 at 5:04:30 PM UTC-5 Edward K. Ream wrote:

Happily, there a simpler way will probably work: have the VNode methods that affect icons call v.updateIcon() directly!

PR #2813 shows that this plan works!!!

The main complication was doing everything using VNodes (not Positions), but the result was a spectacular collapse in complexity!

These are early days, but everything appears to work. Adventurous Leonistas can try the ekr-icons branch. I won't merge this branch until I return from vacation.

Edward
Reply all
Reply to author
Forward
0 new messages