Hi Lex,<br><br>Thanks for your reply.<br>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)...<br>
<br>void document_set_text_changed(GeanyDocument *doc, gboolean changed)<br>{<br>    g_return_if_fail(doc != NULL);<br><br>    doc->changed = changed;<br><br>    if (! main_status.quitting)<br>    {<br>        ui_update_tab_status(doc);<br>
        ui_save_buttons_toggle(changed);<br>        ui_set_window_title(doc);<br>        ui_update_statusbar(doc, -1);<br>    }<br>}<br><br>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.<br>
<br>I'll study the code a bit more to try to understand how the ui updates works.<br><br>Another interesting point is that only ui_update_tab_status(doc) creates a noticeable latency. <br>The other functions: ui_save_buttons_toggle(changed), ui_set_window_title(doc), ui_update_statusbar(doc, -1) seem to be fast.<br>
<br>Thanks again and regards,<br><br>Evandro<br><br><div class="gmail_extra"><br><br><div class="gmail_quote">2012/11/24 Lex Trotman <span dir="ltr"><<a href="mailto:elextr@gmail.com" target="_blank">elextr@gmail.com</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On 24 November 2012 16:15, Evandro Borracini<br>
<div><div class="h5"><<a href="mailto:evandro.borracini@gmail.com">evandro.borracini@gmail.com</a>> wrote:<br>
> Hi,<br>
><br>
> I started using Geany a couple of weeks ago and I noticed a slower response<br>
> to typed text than my previous editor Scite. Running both editors at the<br>
> same time, it was noticeable to me that Geany had a slightly longer latency<br>
> time for printing the characters on the screen (and/or for moving the cursor<br>
> to the next line after hitting the Enter key).<br>
><br>
> Well, I think that might not be noticeable to most of users (since they run<br>
> Geany on fast machines) but It is annoying me because I'm working on a<br>
> shared server (which most of time is very loaded), making the latency even<br>
> bigger. So, I've been trying to identify the cause of the latency.<br>
><br>
> After some experiments and I think I could find the cause and an workaround.<br>
> I just need some help from you guys for getting a final solution.<br>
><br>
> I see that the latency is caused the following sequence of function calls:<br>
><br>
> editor.c: on_editor_notify()  inside "switch (nt->nmhdr.code) ... case<br>
> SCN_MODIFIED" :<br>
>         document_undo_add(doc, UNDO_SCINTILLA, NULL);  (file: document.c)<br>
>             document_set_text_changed(doc, TRUE); (file: document.c)<br>
>                 ui_update_tab_status(doc) (file: ui_utils.c)<br>
>                    sidebar_openfiles_update(doc); (file: ui_utils.c)<br>
><br>
><br>
> It seems that the latency is because sidebar_openfiles_update() is called<br>
> too frequently (apparently at each typed key). I've made an experiment by<br>
> commenting out the call to ui_update_tab_status(doc) (insided<br>
> document_set_text_changed() ) and I got Geany as sharp as Scite!!!    :-)<br>
><br>
> I'd like to propose the fix below (please find the patch in the end of this<br>
> message). It worked fine for me but since I'm not much familiar with Geany<br>
> source code, I need you guys to review it.<br>
><br>
> Could you guys please review my fix? Does any of you see any better<br>
> solution?<br>
><br>
> Please notice that I'm changing two functions:<br>
> document_undo_add() - reduced the latency while typing text<br>
> document_redo_add() - reduced the latency for the undo operation (CTRL+Z)<br>
><br>
> Thanks in advance and regards,<br>
><br>
> Evandro<br>
><br>
><br>
><br>
> diff -Naurp geany-0.20/src/document.c geany-0.20_fast/src/document.c<br>
> --- geany-0.20/src/document.c    2012-11-23 20:22:22.564735000 -0800<br>
> +++ geany-0.20_fast/src/document.c    2012-11-23 20:28:17.535008000 -0800<br>
> @@ -2676,7 +2676,9 @@ void document_undo_add(GeanyDocument *do<br>
><br>
>      g_trash_stack_push(&doc->priv->undo_actions, action);<br>
><br>
> -    document_set_text_changed(doc, TRUE);<br>
> +    /* document_set_text_changed(doc, TRUE); */<br>
<br>
</div></div>Hi,<br>
<br>
I don't think removing a lot of UI update calls is the right solution<br>
unless you can show that they are done elsewhere.  The things that are<br>
done by these calls must be done somewhere to make the UI respond<br>
correctly to document changed status.<br>
<br>
A possible better solution (that I have not tested) is for<br>
document_set_text_changed() to only call the UI updates if the changed<br>
status is changed.<br>
<br>
Cheers<br>
Lex<br>
<div class="im"><br>
> +    doc->changed = TRUE;<br>
> +<br>
>      ui_update_popup_reundo_items(doc);<br>
>  }<br>
><br>
> @@ -2840,7 +2842,9 @@ static void document_redo_add(GeanyDocum<br>
><br>
>      g_trash_stack_push(&doc->priv->redo_actions, action);<br>
><br>
> -    document_set_text_changed(doc, TRUE);<br>
> +    /* document_set_text_changed(doc, TRUE); */<br>
> +    doc->changed = TRUE;<br>
> +<br>
>      ui_update_popup_reundo_items(doc);<br>
>  }<br>
><br>
><br>
><br>
</div>> _______________________________________________<br>
> Devel mailing list<br>
> <a href="mailto:Devel@lists.geany.org">Devel@lists.geany.org</a><br>
> <a href="https://lists.geany.org/cgi-bin/mailman/listinfo/devel" target="_blank">https://lists.geany.org/cgi-bin/mailman/listinfo/devel</a><br>
><br>
_______________________________________________<br>
Devel mailing list<br>
<a href="mailto:Devel@lists.geany.org">Devel@lists.geany.org</a><br>
<a href="https://lists.geany.org/cgi-bin/mailman/listinfo/devel" target="_blank">https://lists.geany.org/cgi-bin/mailman/listinfo/devel</a><br>
</blockquote></div><br></div>