gtranslator r3639 - in trunk/src: . translation-memory/berkeley



Author: icq
Date: Mon Sep 22 09:40:27 2008
New Revision: 3639
URL: http://svn.gnome.org/viewvc/gtranslator?rev=3639&view=rev

Log:
2008-08-01  Ignacio Casal Quinteiro  <nacho resa gmail com>

	* translation-memory/berkeley/berkeley.c (insert_match_sorted),
	(gtranslator_berkeley_lookup):
	Take advantage of create the list to insert the values already sorted.

Modified:
   trunk/src/ChangeLog
   trunk/src/translation-memory/berkeley/berkeley.c

Modified: trunk/src/translation-memory/berkeley/berkeley.c
==============================================================================
--- trunk/src/translation-memory/berkeley/berkeley.c	(original)
+++ trunk/src/translation-memory/berkeley/berkeley.c	Mon Sep 22 09:40:27 2008
@@ -454,6 +454,21 @@
 	RETURN_WITH_CLEANUP(FALSE)
 }
 
+static gint
+insert_match_sorted (gconstpointer a,
+		     gconstpointer b)
+{
+	GtranslatorTranslationMemoryMatch *match1 = (GtranslatorTranslationMemoryMatch *)a;
+	GtranslatorTranslationMemoryMatch *match2 = (GtranslatorTranslationMemoryMatch *)b;
+	
+	if (match1->level < match2->level)
+		return -1;
+	else if (match1->level > match2->level)
+		return 1;
+	else
+		return 0;
+}
+
 static GList *
 gtranslator_berkeley_lookup (GtranslatorTranslationMemory *tm,
 			     const gchar *phrase)
@@ -516,7 +531,8 @@
 		match->match = g_strdup (hkey);
 		match->level = GPOINTER_TO_INT (value);
 		
-		matches = g_list_append (matches, match);
+		matches = g_list_insert_sorted (matches, match,
+						(GCompareFunc)insert_match_sorted);
 		index++;
 	}
 



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