diff options
author | Denis Kenzior <denkenz@gmail.com> | 2012-09-11 22:31:44 -0500 |
---|---|---|
committer | Denis Kenzior <denkenz@gmail.com> | 2012-09-11 22:33:43 -0500 |
commit | 2dac10e1cb2d86e88dffe67569888bb9c110be9d (patch) | |
tree | d2cd7bc7a6b8538ae99924c1ea75f538116deac2 /src | |
parent | 80fb1c2fac738bd27111d4849b649e57a17ac65f (diff) | |
download | ofono-2dac10e1cb2d86e88dffe67569888bb9c110be9d.tar.bz2 |
sms: Optimize behavior of previous commit
The previous commit fixed the bug, however performing a linear-search
through the entire tx-queue is quite wasteful. The current usage
pattern is to always modify the entry at the tail of the queue, so
optimize.
Diffstat (limited to 'src')
-rw-r--r-- | src/sms.c | 12 |
1 files changed, 7 insertions, 5 deletions
@@ -2115,14 +2115,16 @@ int __ofono_sms_txq_set_submit_notify(struct ofono_sms *sms, ofono_destroy_func destroy) { GList *l; - struct tx_queue_entry *entry; + struct tx_queue_entry *entry = g_queue_peek_tail(sms->txq); - l = g_queue_find_custom(sms->txq, uuid, entry_compare_by_uuid); + if (memcmp(&entry->uuid, uuid, sizeof(entry->uuid))) { + l = g_queue_find_custom(sms->txq, uuid, entry_compare_by_uuid); - if (l == NULL) - return -ENOENT; + if (l == NULL) + return -ENOENT; - entry = l->data; + entry = l->data; + } tx_queue_entry_set_submit_notify(entry, cb, data, destroy); |