[pkg-fso-commits] [SCM] FSO frameworkd Debian packaging branch, debian, updated. upstream/0.9.5.5-717-g0f98819

Sebastian Krzyszkowiak seba.dos1 at gmail.com
Sat Aug 6 08:17:22 UTC 2011


The following commit has been merged in the debian branch:
commit 6133a62b3a5d4788a948f9389ca8b6d422109bbe
Author: Sebastian Krzyszkowiak <seba.dos1 at gmail.com>
Date:   Sat Jul 11 00:03:00 2009 +0200

    opimd: remove unnecessary transformations. Should speed up a litle quering.

diff --git a/framework/subsystems/opimd/pimd_calls.py b/framework/subsystems/opimd/pimd_calls.py
index 7d3d77e..bb40132 100644
--- a/framework/subsystems/opimd/pimd_calls.py
+++ b/framework/subsystems/opimd/pimd_calls.py
@@ -70,8 +70,7 @@ class CallQueryMatcher(object):
 
         assert(self.query_obj, "Query object is empty, cannot match!")
 
-        result_count = 0
-        matches = {}
+        matches = []
         results = []
 
         # Match all calls
@@ -79,25 +78,23 @@ class CallQueryMatcher(object):
             if call:
                 match = call.match_query(self.query_obj)
                 if match > _MIN_MATCH_TRESHOLD:
-                    matches[call_id] = match
-                    result_count += 1
+                    matches.append((match, call_id))
 
+        result_count = len(matches)
         # Sort matches by relevance and return the best hits
         if result_count > 0:
-            # Transform the dict into a list of key/value tuples so we can sort it
-            kv_list = [(v, k) for k, v in matches.items()]
-            kv_list.sort()
+            matches.sort()
 
             try:
                 limit = self.query_obj["_limit"]
-                if limit>len(kv_list):
-                    limit = len(kv_list)
+                if limit > result_count:
+                    limit = result_count
             except KeyError:
-                limit = len(kv_list)
+                limit = result_count
 
             # Append the call IDs to the result list in the order of the sorted list
             for i in range(limit):
-                results.append(kv_list[i][1])
+                results.append(matches[i][1])
 
         return results
 
diff --git a/framework/subsystems/opimd/pimd_contacts.py b/framework/subsystems/opimd/pimd_contacts.py
index 045823d..9eda8f3 100644
--- a/framework/subsystems/opimd/pimd_contacts.py
+++ b/framework/subsystems/opimd/pimd_contacts.py
@@ -66,8 +66,7 @@ class ContactQueryMatcher(object):
 
         assert(self.query_obj, "Query object is empty, cannot match!")
 
-        result_count = 0
-        matches = {}
+        matches = []
         results = []
 
         # Match all contacts
@@ -75,25 +74,23 @@ class ContactQueryMatcher(object):
             if contact:
                 match = contact.match_query(self.query_obj)
                 if match > _MIN_MATCH_TRESHOLD:
-                    matches[contact_id] = match
-                    result_count += 1
+                    matches.append((match, contact_id))
 
+        result_count = len(matches)
         # Sort matches by relevance and return the best hits
         if result_count > 0:
-            # Transform the dict into a list of key/value tuples so we can sort it
-            kv_list = [(v, k) for k, v in matches.items()]
-            kv_list.sort()
+            matches.sort()
 
             try:
                 limit = self.query_obj["_limit"]
-                if limit>len(kv_list):
-                    limit = len(kv_list)
+                if limit > result_count:
+                    limit = result_count
             except KeyError:
-                limit = len(kv_list)
+                limit = result_count
 
             # Append the contact IDs to the result list in the order of the sorted list
             for i in range(limit):
-                results.append(kv_list[i][1])
+                results.append(matches[i][1])
 
         return results
 
diff --git a/framework/subsystems/opimd/pimd_messages.py b/framework/subsystems/opimd/pimd_messages.py
index ae8d784..95bcddc 100644
--- a/framework/subsystems/opimd/pimd_messages.py
+++ b/framework/subsystems/opimd/pimd_messages.py
@@ -71,8 +71,7 @@ class MessageQueryMatcher(object):
 
         assert(self.query_obj, "Query object is empty, cannot match!")
 
-        result_count = 0
-        matches = {}
+        matches = []
         results = []
 
         # Match all messages
@@ -80,25 +79,23 @@ class MessageQueryMatcher(object):
             if message:
                 match = message.match_query(self.query_obj)
                 if match > _MIN_MATCH_TRESHOLD:
-                    matches[message_id] = match
-                    result_count += 1
+                    matches.append((match, message_id))
 
+        result_count = len(matches)
         # Sort matches by relevance and return the best hits
         if result_count > 0:
-            # Transform the dict into a list of key/value tuples so we can sort it
-            kv_list = [(v, k) for k, v in matches.items()]
-            kv_list.sort()
+            matches.sort()
 
             try:
                 limit = self.query_obj["_limit"]
-                if limit>len(kv_list):
-                    limit = len(kv_list)
+                if limit > result_count:
+                    limit = result_count
             except KeyError:
-                limit = len(kv_list)
+                limit = result_count
 
             # Append the message IDs to the result list in the order of the sorted list
             for i in range(limit):
-                results.append(kv_list[i][1])
+                results.append(matches[i][1])
 
         return results
 

-- 
FSO frameworkd Debian packaging



More information about the pkg-fso-commits mailing list