comparison libpurple/plugins/log_reader.c @ 18249:35d981091506

Prepend to lists for performance, and use g_list_reverse when the list is being built in reverse order (as opposed to random order, like when we're getting files from a readdir()) to improve the performance of the sort that'll happen later in the core logging code.
author Richard Laager <rlaager@wiktel.com>
date Sun, 24 Jun 2007 23:52:08 +0000
parents ab761acbc614
children 7a6a1da4121b
comparison
equal deleted inserted replaced
18248:ab761acbc614 18249:35d981091506
155 /* XXX: Look into this later... Should we pass in a struct tm? */ 155 /* XXX: Look into this later... Should we pass in a struct tm? */
156 log = purple_log_new(PURPLE_LOG_IM, sn, account, NULL, mktime(&tm), NULL); 156 log = purple_log_new(PURPLE_LOG_IM, sn, account, NULL, mktime(&tm), NULL);
157 log->logger = adium_logger; 157 log->logger = adium_logger;
158 log->logger_data = data; 158 log->logger_data = data;
159 159
160 list = g_list_append(list, log); 160 list = g_list_prepend(list, log);
161 } 161 }
162 } else if (purple_str_has_suffix(file, ".adiumLog")) { 162 } else if (purple_str_has_suffix(file, ".adiumLog")) {
163 struct tm tm; 163 struct tm tm;
164 const char *date = file; 164 const char *date = file;
165 165
216 /* XXX: Look into this later... Should we pass in a struct tm? */ 216 /* XXX: Look into this later... Should we pass in a struct tm? */
217 log = purple_log_new(PURPLE_LOG_IM, sn, account, NULL, mktime(&tm), NULL); 217 log = purple_log_new(PURPLE_LOG_IM, sn, account, NULL, mktime(&tm), NULL);
218 log->logger = adium_logger; 218 log->logger = adium_logger;
219 log->logger_data = data; 219 log->logger_data = data;
220 220
221 list = g_list_append(list, log); 221 list = g_list_prepend(list, log);
222 } 222 }
223 } 223 }
224 } 224 }
225 g_dir_close(dir); 225 g_dir_close(dir);
226 } 226 }
855 855
856 log = purple_log_new(PURPLE_LOG_IM, sn, account, NULL, stamp, tm); 856 log = purple_log_new(PURPLE_LOG_IM, sn, account, NULL, stamp, tm);
857 log->logger = msn_logger; 857 log->logger = msn_logger;
858 log->logger_data = data; 858 log->logger_data = data;
859 859
860 list = g_list_append(list, log); 860 list = g_list_prepend(list, log);
861 } 861 }
862 old_session_id = session_id; 862 old_session_id = session_id;
863 } 863 }
864 864
865 if (data) 865 if (data)
866 data->last_log = TRUE; 866 data->last_log = TRUE;
867 867
868 return list; 868 return g_list_reverse(list);
869 } 869 }
870 870
871 static char * msn_logger_read (PurpleLog *log, PurpleLogReadFlags *flags) 871 static char * msn_logger_read (PurpleLog *log, PurpleLogReadFlags *flags)
872 { 872 {
873 struct msn_logger_data *data; 873 struct msn_logger_data *data;
1395 log = purple_log_new(PURPLE_LOG_IM, 1395 log = purple_log_new(PURPLE_LOG_IM,
1396 sn, account, NULL, mktime(&tm), NULL); 1396 sn, account, NULL, mktime(&tm), NULL);
1397 log->logger = trillian_logger; 1397 log->logger = trillian_logger;
1398 log->logger_data = data; 1398 log->logger_data = data;
1399 1399
1400 list = g_list_append(list, log); 1400 list = g_list_prepend(list, log);
1401 } 1401 }
1402 } 1402 }
1403 } 1403 }
1404 c++; 1404 c++;
1405 line = c; 1405 line = c;
1410 } 1410 }
1411 g_free(path); 1411 g_free(path);
1412 1412
1413 g_free(prpl_name); 1413 g_free(prpl_name);
1414 1414
1415 return list; 1415 return g_list_reverse(list);
1416 } 1416 }
1417 1417
1418 static char * trillian_logger_read (PurpleLog *log, PurpleLogReadFlags *flags) 1418 static char * trillian_logger_read (PurpleLog *log, PurpleLogReadFlags *flags)
1419 { 1419 {
1420 struct trillian_logger_data *data; 1420 struct trillian_logger_data *data;
1890 NULL, mktime(&prev_tm), NULL); 1890 NULL, mktime(&prev_tm), NULL);
1891 1891
1892 log->logger = qip_logger; 1892 log->logger = qip_logger;
1893 log->logger_data = data; 1893 log->logger_data = data;
1894 1894
1895 list = g_list_append(list, log); 1895 list = g_list_prepend(list, log);
1896 1896
1897 prev_tm = tm; 1897 prev_tm = tm;
1898 start_log = new_line; 1898 start_log = new_line;
1899 } 1899 }
1900 } 1900 }
1929 NULL, mktime(&prev_tm), NULL); 1929 NULL, mktime(&prev_tm), NULL);
1930 1930
1931 log->logger = qip_logger; 1931 log->logger = qip_logger;
1932 log->logger_data = data; 1932 log->logger_data = data;
1933 1933
1934 list = g_list_append(list, log); 1934 list = g_list_prepend(list, log);
1935 } 1935 }
1936 1936
1937 g_free(contents); 1937 g_free(contents);
1938 g_free(path); 1938 g_free(path);
1939 return list; 1939 return g_list_reverse(list);
1940 } 1940 }
1941 1941
1942 static char * qip_logger_read (PurpleLog *log, PurpleLogReadFlags *flags) 1942 static char * qip_logger_read (PurpleLog *log, PurpleLogReadFlags *flags)
1943 { 1943 {
1944 struct qip_logger_data *data; 1944 struct qip_logger_data *data;