Skip to content

Make session.active_annotation([type]) a derived? #186

@michael

Description

@michael

I guess Svedit could save some CPU cycles turning the session.active_annotation function call into a derived, as it's called in many places, and now also in AnnotatedTextProperty (which essentially means for each text piece in the document, potentially tens of thousands in large documents).

So maybe instead I could compute this once for the document and then you'd just access the derived value in different places. E.g. in ToggleLinkCOmmand instead of

const can_remove_link = session.active_annotation('link');

we'd do:

const can_remove_link = session.active_annotation?.type === 'link';

Anyways I should generally do an iteration to optimize performance for large docs. This may be just one tiny thing. Need to better understand what happens when the Svedit component rerenders, like how exactly does each child component find out wether it must rerender or not? How much computation is involved there. Because I noticed on large documents, each keystroke has a bit of a delay, but I'd hope I can optimize it so that only the part of the graph that has been modified needs recomputation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions