[Geany-Devel] Making Geany faster (reducing latency to typed text)

Colomban Wendling lists.ban at herbesfolles.org
Sat Nov 24 14:04:22 UTC 2012


Le 24/11/2012 14:48, Evandro Borracini a écrit :
> Hi Lex,
> 
> Thanks for your reply.
> In the original code, document_redo/undo_add() calls
> document_set_text_changed(doc, TRUE) so it's hardcoded with changed=TRUE
> and it would always call the ui updates even if we added an if (changed
> == TRUE)...
> 
> void document_set_text_changed(GeanyDocument *doc, gboolean changed)
> {
>     g_return_if_fail(doc != NULL);
> 
>     doc->changed = changed;
> 
>     if (! main_status.quitting)
>     {
>         ui_update_tab_status(doc);
>         ui_save_buttons_toggle(changed);
>         ui_set_window_title(doc);
>         ui_update_statusbar(doc, -1);
>     }
> }

A solution might be to only do the updates if (doc->changed != changed).
 I didn't look at the interactions with the rest of Geany (nor test it
actually), but looking at this I guess that changing it to:


void document_set_text_changed(GeanyDocument *doc, gboolean changed)
{
    g_return_if_fail(doc != NULL);

    if (doc->changed != changed && ! main_status.quitting)
    {
        doc->changed = changed; /* maybe this should also be called if
                                 * (main_status.quitting), but I'm not
                                 * sure it's necessary */
        ui_update_tab_status(doc);
        ui_save_buttons_toggle(changed);
        ui_set_window_title(doc);
        ui_update_statusbar(doc, -1);
    }
}


would work and fix the issue without changing the code much.

Cheers,
Colomban

> 
> Interestingly, is that I still see updates in the sidebar, buttons,
> windows title and status bar after commenting out the call to
> document_set_text_changed() inside document_redo/undo_add().  So, I
> think it's called elsewhere.
> 
> I'll study the code a bit more to try to understand how the ui updates
> works.
> 
> Another interesting point is that only ui_update_tab_status(doc) creates
> a noticeable latency.
> The other functions: ui_save_buttons_toggle(changed),
> ui_set_window_title(doc), ui_update_statusbar(doc, -1) seem to be fast.


More information about the Devel mailing list