Recomputing everything is certainly easier to code, and apparently the other platforms don't need the optimization as much as Linux does, even though it will improve performance.runrevmark wrote:@ricochet1k: Good find! I'd actually forgotten the field was 'dumb' enough to do that! As for why it does it, then lack of time to optimise appropriately is perhaps all I can say. Certainly if you can make it so paragraphs recalculate when changed that would make a big difference - then making it so blocks only recalc when adjusted that would most likely obviate the need for a 'textwidth' cache.
No problem. I've always liked this engine since I got introduced to it volunteering at CMSEC a few years ago. It's been fun learning how it works.runrevmark wrote:Btw, it's great to get another set of eyes on stuff like this - I've done a lot of work in the field over the years and it's easy to get entrenched and develop 'code-blindness' with such things
Anyway, my ideas for optimization so far:
- Paragraphs only need a layout when a property of them changes or text is altered, or when a text-related property of the field changes.
- Block textwidth only needs to change when a font property changes or text is altered, or when a text-related property of the field changes.
- Blocks should be split on tab boundaries, so that their width (or a separate inner width) won't need to be recalculated whenever the tab width changes, and it can just check for a tab an then get the width of everything else, instead of having to scan for tabs.
- The lines in a paragraph shouldn't need to be recreated unless dontWrap is off and the width of one of the lines changes significantly.
I'm still quite new to this code, any suggestions/ideas would be appreciated.
EDIT: One I forgot to mention: If each object keeps track of its own dirty state somehow, it would be able to do the layout calculations before the next field redraw instead of immediately, which should mean that many sequential changes to the text of the field won't be slowed down by layout computations.