[gitg] Improve hash search performance



commit ac99cfa64621593f2cd21b1af6de63634b84c837
Author: Guilhem Bonnefille <guilhem bonnefille gmail com>
Date:   Tue Apr 28 20:36:52 2009 +0200

    Improve hash search performance
    
    g_str_has_prefix is forcibly better than strncmp+strlen (key array read twice).

 gitg/gitg-window.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
---
diff --git a/gitg/gitg-window.c b/gitg/gitg-window.c
index 006a366..32f49cb 100644
--- a/gitg/gitg-window.c
+++ b/gitg/gitg-window.c
@@ -266,9 +266,9 @@ search_hash_equal_func(GtkTreeModel *model, gchar const *key, GtkTreeIter *iter)
 	gtk_tree_model_get(model, iter, 0, &rv, -1);
 
 	gchar *sha = gitg_revision_get_sha1(rv);
-
-	gboolean ret = strncmp(sha, key, strlen(key)) != 0;
-
+	
+	gboolean ret = !g_str_has_prefix(sha, key);
+	
 	g_free(sha);
 	gitg_revision_unref(rv);
 



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