[gnome-todo] todo.txt: don't call strlen repeatedly in loop



commit 9018ab330b8353dd7cdc89eaa0dba09a3d8e40e7
Author: Mohammed Sadiq <sadiq sadiqpk org>
Date:   Sun Apr 9 10:02:57 2017 +0530

    todo.txt: don't call strlen repeatedly in loop
    
    https://bugzilla.gnome.org/show_bug.cgi?id=781080

 plugins/todo-txt/gtd-todo-txt-parser.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)
---
diff --git a/plugins/todo-txt/gtd-todo-txt-parser.c b/plugins/todo-txt/gtd-todo-txt-parser.c
index 574fc4a..aeedcbc 100644
--- a/plugins/todo-txt/gtd-todo-txt-parser.c
+++ b/plugins/todo-txt/gtd-todo-txt-parser.c
@@ -135,8 +135,11 @@ gboolean
 gtd_todo_txt_parser_is_word (gchar *token)
 {
   guint pos;
+  guint token_length;
 
-  for (pos = 0; pos < strlen (token); pos++)
+  token_length = g_utf8_strlen (token, -1);
+
+  for (pos = 0; pos < token_length; pos++)
     {
       if (!g_unichar_isalnum (token[pos]))
         return FALSE;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]