diff options
author | Charles Kerr <charles.kerr@canonical.com> | 2012-03-18 10:01:44 -0500 |
---|---|---|
committer | Charles Kerr <charles.kerr@canonical.com> | 2012-03-18 10:01:44 -0500 |
commit | c31a4b20e1029de61406a204a462d2e233b2e7e6 (patch) | |
tree | 688e6ef889a7d2b07042da796db499347ed19018 | |
parent | 881607dfdbe95f1e4759033d87ab064010dd8e44 (diff) | |
download | ayatana-indicator-datetime-c31a4b20e1029de61406a204a462d2e233b2e7e6.tar.gz ayatana-indicator-datetime-c31a4b20e1029de61406a204a462d2e233b2e7e6.tar.bz2 ayatana-indicator-datetime-c31a4b20e1029de61406a204a462d2e233b2e7e6.zip |
minor: fix inefficient GSList walking -- only walk a GSList once instead of twice per node
-rw-r--r-- | src/datetime-service.c | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/src/datetime-service.c b/src/datetime-service.c index e00ff86..7d4a9f2 100644 --- a/src/datetime-service.c +++ b/src/datetime-service.c @@ -772,23 +772,17 @@ update_appointment_menu_items (gpointer user_data) g_object_unref(ecal); continue; } + const gchar *ecal_uid = e_source_peek_uid(source); - gboolean match = FALSE; g_debug("Checking ecal_uid is enabled: %s", ecal_uid); - for (i = 0; i<g_slist_length(cal_list);i++) { - char *cuid = (char *)g_slist_nth_data(cal_list, i); - if (g_strcmp0(cuid, ecal_uid) == 0) { - match = TRUE; - break; - } - } - if (!match) { + const gboolean in_list = g_slist_find_custom (cal_list, ecal_uid, (GCompareFunc)g_strcmp0) != NULL; + if (!in_list) { g_object_unref(ecal); continue; } + g_debug("ecal_uid is enabled, generating instances"); - - e_cal_generate_instances (ecal, t1, t2, (ECalRecurInstanceFn) populate_appointment_instances, (gpointer) source); + e_cal_generate_instances (ecal, t1, t2, (ECalRecurInstanceFn) populate_appointment_instances, source); g_object_unref(ecal); } } |