[Geany-Devel] Making Geany faster (reducing latency to typed text)
Evandro Borracini
evandro.borracini at gmail.com
Sun Nov 25 15:42:41 UTC 2012
Thanks Dimitar,
I've updated the patch to always call document_set_text_changed() for
BOM/ENCODING. For UNDO_SCINTILLA, document_set_text_changed() is called
only at the first document change.
I've tested and it worked fine for me. The latency while typing is gone.
As expected, we still have a small latency at the first key hit but that
doesn't create any trouble at all.
The new patch is below.
Best 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-25 07:16:47.602542000 -0800
@@ -2676,7 +2676,10 @@ void document_undo_add(GeanyDocument *do
g_trash_stack_push(&doc->priv->undo_actions, action);
- document_set_text_changed(doc, TRUE);
+ if ((type != UNDO_SCINTILLA) || (doc->changed != TRUE)) {
+ document_set_text_changed(doc, TRUE);
+ }
+
ui_update_popup_reundo_items(doc);
}
@@ -2840,7 +2843,10 @@ static void document_redo_add(GeanyDocum
g_trash_stack_push(&doc->priv->redo_actions, action);
- document_set_text_changed(doc, TRUE);
+ if ((type != UNDO_SCINTILLA) || (doc->changed != TRUE)) {
+ document_set_text_changed(doc, TRUE);
+ }
+
ui_update_popup_reundo_items(doc);
}
2012/11/25 Dimitar Zhekov <dimitar.zhekov at gmail.com>
> On Sat, 24 Nov 2012 14:09:12 +0000
> Nick Treleaven <nick.treleaven at btinternet.com> wrote:
>
> > I played with this a little. It won't work easily because
> > document_set_text_changed is sometimes called to force a UI update,
> > possibly even when the current doc hasn't changed. [...]
>
> On Sat, 24 Nov 2012 15:11:48 -0600
> Evandro Borracini <evandro.borracini at gmail.com> wrote:
>
> > Thanks everyone for the comments and suggestions. Based on them, I
> > reverted back to the original code and just added an "if
> > (doc->changed != TRUE)" before calling document_set_text_changed
> > (doc, TRUE) in document_undo/redo_add().
>
> document_redo_add(doc, UNDO_SCINTILLA, NULL); <-- text changed
> document_redo_add(doc, UNDO_BOM, GINT_TO_POINTER(doc->has_bom));
> document_redo_add(doc, UNDO_ENCODING, g_strdup(doc->encoding));
>
> The 2nd and 3rd call probably rely on redo_add to call
> document_set_text_changed(), to update the status bar. You can check
> that (my Geany version is a bit outdated), and update the patch to
> call set_text for BOM/ENCODING (they are rare). Same for undo.
>
> Aside from that, the patch looks reasonable. For plugins, we allow
> document_set_text_changed(), but not undo/redo_add(), which is OK.
>
> --
> E-gards: Jimmy
> _______________________________________________
> Devel mailing list
> Devel at lists.geany.org
> https://lists.geany.org/cgi-bin/mailman/listinfo/devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.geany.org/pipermail/devel/attachments/20121125/4b5c4f08/attachment.html>
More information about the Devel
mailing list