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

Lex Trotman elextr at gmail.com
Sat Nov 24 06:56:50 UTC 2012


On 24 November 2012 16:15, Evandro Borracini
<evandro.borracini at gmail.com> wrote:
> Hi,
>
> I started using Geany a couple of weeks ago and I noticed a slower response
> to typed text than my previous editor Scite. Running both editors at the
> same time, it was noticeable to me that Geany had a slightly longer latency
> time for printing the characters on the screen (and/or for moving the cursor
> to the next line after hitting the Enter key).
>
> Well, I think that might not be noticeable to most of users (since they run
> Geany on fast machines) but It is annoying me because I'm working on a
> shared server (which most of time is very loaded), making the latency even
> bigger. So, I've been trying to identify the cause of the latency.
>
> After some experiments and I think I could find the cause and an workaround.
> I just need some help from you guys for getting a final solution.
>
> I see that the latency is caused the following sequence of function calls:
>
> editor.c: on_editor_notify()  inside "switch (nt->nmhdr.code) ... case
> SCN_MODIFIED" :
>         document_undo_add(doc, UNDO_SCINTILLA, NULL);  (file: document.c)
>             document_set_text_changed(doc, TRUE); (file: document.c)
>                 ui_update_tab_status(doc) (file: ui_utils.c)
>                    sidebar_openfiles_update(doc); (file: ui_utils.c)
>
>
> It seems that the latency is because sidebar_openfiles_update() is called
> too frequently (apparently at each typed key). I've made an experiment by
> commenting out the call to ui_update_tab_status(doc) (insided
> document_set_text_changed() ) and I got Geany as sharp as Scite!!!    :-)
>
> I'd like to propose the fix below (please find the patch in the end of this
> message). It worked fine for me but since I'm not much familiar with Geany
> source code, I need you guys to review it.
>
> Could you guys please review my fix? Does any of you see any better
> solution?
>
> Please notice that I'm changing two functions:
> document_undo_add() - reduced the latency while typing text
> document_redo_add() - reduced the latency for the undo operation (CTRL+Z)
>
> Thanks in advance and regards,
>
> Evandro
>
>
>
> diff -Naurp geany-0.20/src/document.c geany-0.20_fast/src/document.c
> --- geany-0.20/src/document.c    2012-11-23 20:22:22.564735000 -0800
> +++ geany-0.20_fast/src/document.c    2012-11-23 20:28:17.535008000 -0800
> @@ -2676,7 +2676,9 @@ void document_undo_add(GeanyDocument *do
>
>      g_trash_stack_push(&doc->priv->undo_actions, action);
>
> -    document_set_text_changed(doc, TRUE);
> +    /* document_set_text_changed(doc, TRUE); */

Hi,

I don't think removing a lot of UI update calls is the right solution
unless you can show that they are done elsewhere.  The things that are
done by these calls must be done somewhere to make the UI respond
correctly to document changed status.

A possible better solution (that I have not tested) is for
document_set_text_changed() to only call the UI updates if the changed
status is changed.

Cheers
Lex

> +    doc->changed = TRUE;
> +
>      ui_update_popup_reundo_items(doc);
>  }
>
> @@ -2840,7 +2842,9 @@ static void document_redo_add(GeanyDocum
>
>      g_trash_stack_push(&doc->priv->redo_actions, action);
>
> -    document_set_text_changed(doc, TRUE);
> +    /* document_set_text_changed(doc, TRUE); */
> +    doc->changed = TRUE;
> +
>      ui_update_popup_reundo_items(doc);
>  }
>
>
>
> _______________________________________________
> Devel mailing list
> Devel at lists.geany.org
> https://lists.geany.org/cgi-bin/mailman/listinfo/devel
>


More information about the Devel mailing list