[gnome-text-editor] spellcheck: short-circuit known spaces
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-text-editor] spellcheck: short-circuit known spaces
- Date: Sun, 18 Jul 2021 17:07:42 +0000 (UTC)
commit 2d3d3ddedabe00755a7f22803e6ff37f431cc200
Author: Christian Hergert <chergert redhat com>
Date: Sun Jul 18 10:07:37 2021 -0700
spellcheck: short-circuit known spaces
We want to avoid iterating the full list of extra_word_chars (which can
be quite long) for very common stuff.
src/editor-spell-cursor.c | 4 ++++
1 file changed, 4 insertions(+)
---
diff --git a/src/editor-spell-cursor.c b/src/editor-spell-cursor.c
index 52e6df4..52731f3 100644
--- a/src/editor-spell-cursor.c
+++ b/src/editor-spell-cursor.c
@@ -155,6 +155,10 @@ is_extra_word_char (const GtkTextIter *iter,
{
gunichar ch = gtk_text_iter_get_char (iter);
+ /* Short-circuit for known space */
+ if (ch == ' ' || ch == '\n' || ch == '\t' || ch == '\r')
+ return FALSE;
+
for (const char *c = extra_word_chars; *c; c = g_utf8_next_char (c))
{
if (ch == g_utf8_get_char (c))
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]