cpw.nader.asynclogging-3: 7813c10c: Reduced CPU usage by making the logs be ...
morshed.nader at gmail.com
morshed.nader at gmail.com
Sun Jan 8 01:21:25 EST 2012
----------------------------------------------------------------------
Revision: 7813c10c8b2155741f2e40bad315473b48a1b39d
Parent: 3a7e85c07b3edd7595e47a2b92ae924ac65467ec
Author: morshed.nader at gmail.com
Date: 01/07/12 17:15:01
Branch: im.pidgin.cpw.nader.asynclogging-3
URL: http://d.pidgin.im/viewmtn/revision/info/7813c10c8b2155741f2e40bad315473b48a1b39d
Changelog:
Reduced CPU usage by making the logs be returned in sets of 50, rather than 1 at a time
Changes against parent 3a7e85c07b3edd7595e47a2b92ae924ac65467ec
patched libpurple/log.c
-------------- next part --------------
============================================================
--- libpurple/log.c f323cbda89e0f0653a8fff89baba94117ac3783f
+++ libpurple/log.c 3acaac437d75ea0f965b26dc3bd632a96d1ac718
@@ -40,7 +40,7 @@
/* Helpful macros */
-#define FILES_PER_SEARCH 20
+#define FILES_PER_SEARCH 50
#define PURPLE_IS_ACCOUNT(account) (account != NULL)
#define PURPLE_IS_CONVERSATION(conv) (conv != NULL)
@@ -160,6 +160,8 @@ typedef struct {
guint reads;
gchar *search_term;
GList *logs;
+ GList *success_buffer;
+ guint success_len;
} search_callback_data;
typedef struct {
@@ -1131,6 +1133,8 @@ purple_logs_search_async(PurpleLogChatTy
data->lists = 0;
data->reads = 0;
data->logs = NULL;
+ data->success_buffer = NULL;
+ data->success_len = 0;
data->search_term = g_strdup(search_term);
/* Indicates if we're using the list_async + read_async commands at all */
@@ -2174,11 +2178,20 @@ log_search_read_cb(GObject *object, GAsy
purple_debug_error("log", "Error reading log: %s\n",
error->message);
} else if (*text && purple_strcasestr(text, data->search_term)) {
- SIMPLE_ASYNC_RESULT_NEW_GOOD(NULL, data->cb, data->userdata,
- purple_logs_search_async,
- g_simple_async_result_set_op_res_gpointer,
- g_list_prepend(NULL, g_object_ref(log)),
- (GDestroyNotify) purple_log_list_free);
+ data->success_buffer = g_list_prepend(data->success_buffer,
+ g_object_ref(log));
+ data->success_len++;
+
+ if (data->success_len >= FILES_PER_SEARCH) {
+ SIMPLE_ASYNC_RESULT_NEW_GOOD(NULL, data->cb, data->userdata,
+ purple_logs_search_async,
+ g_simple_async_result_set_op_res_gpointer,
+ data->success_buffer,
+ (GDestroyNotify) purple_log_list_free);
+
+ data->success_buffer = NULL;
+ data->success_len = 0;
+ }
}
g_free(text);
@@ -2200,7 +2213,18 @@ log_search_read_cb(GObject *object, GAsy
g_object_unref(log);
}
- } else
+ } else {
+ if (data->success_buffer != NULL) {
+ SIMPLE_ASYNC_RESULT_NEW_GOOD(NULL, data->cb, data->userdata,
+ purple_logs_search_async,
+ g_simple_async_result_set_op_res_gpointer,
+ data->success_buffer,
+ (GDestroyNotify) purple_log_list_free);
+
+ data->success_buffer = NULL;
+ data->success_len = 0;
+ }
+
log_search_cb(NULL, NULL, data);
}
}
More information about the Commits
mailing list