Mercurial > dovecot > core-2.2
changeset 19776:d49645a28c44
lib-index: Code cleanup - moved code to tview_lookup_ext_update()
No functional changes.
author | Timo Sirainen <timo.sirainen@dovecot.fi> |
---|---|
date | Fri, 19 Feb 2016 19:08:43 +0200 |
parents | 2c94f592e9dd |
children | bcdda0e61d7d |
files | src/lib-index/mail-index-transaction-view.c |
diffstat | 1 files changed, 27 insertions(+), 21 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-index/mail-index-transaction-view.c Fri Feb 19 16:13:51 2016 +0200 +++ b/src/lib-index/mail-index-transaction-view.c Fri Feb 19 19:08:43 2016 +0200 @@ -321,16 +321,6 @@ } } -static struct mail_index_map * -tview_get_lookup_map(struct mail_index_view_transaction *tview) -{ - if (tview->lookup_map == NULL) { - tview->lookup_map = - mail_index_map_clone(tview->view.index->map); - } - return tview->lookup_map; -} - static const void * tview_return_updated_ext(struct mail_index_view_transaction *tview, uint32_t seq, const void *data, uint32_t ext_id) @@ -402,6 +392,32 @@ return ext_id < count && resets[ext_id].new_reset_id != 0; } +static bool +tview_lookup_ext_update(struct mail_index_view_transaction *tview, uint32_t seq, + uint32_t ext_id, struct mail_index_map **map_r, + const void **data_r) +{ + const ARRAY_TYPE(seq_array) *ext_buf; + const void *data; + unsigned int idx; + uint32_t map_ext_idx; + + ext_buf = array_idx(&tview->t->ext_rec_updates, ext_id); + if (!array_is_created(ext_buf) || + !mail_index_seq_array_lookup(ext_buf, seq, &idx)) + return FALSE; + + if (tview->lookup_map == NULL) { + tview->lookup_map = + mail_index_map_clone(tview->view.index->map); + } + + data = array_idx(ext_buf, idx); + *map_r = tview->lookup_map; + *data_r = tview_return_updated_ext(tview, seq, data, ext_id); + return TRUE; +} + static void tview_lookup_ext_full(struct mail_index_view *view, uint32_t seq, uint32_t ext_id, struct mail_index_map **map_r, @@ -409,9 +425,6 @@ { struct mail_index_view_transaction *tview = (struct mail_index_view_transaction *)view; - const ARRAY_TYPE(seq_array) *ext_buf; - const void *data; - unsigned int idx; i_assert(ext_id < array_count(&view->index->extensions)); @@ -422,15 +435,8 @@ ext_id < array_count(&tview->t->ext_rec_updates)) { /* there are some ext updates in transaction. see if there's any for this sequence. */ - ext_buf = array_idx(&tview->t->ext_rec_updates, ext_id); - if (array_is_created(ext_buf) && - mail_index_seq_array_lookup(ext_buf, seq, &idx)) { - data = array_idx(ext_buf, idx); - *map_r = tview_get_lookup_map(tview); - *data_r = tview_return_updated_ext(tview, seq, data, - ext_id); + if (tview_lookup_ext_update(tview, seq, ext_id, map_r, data_r)) return; - } } /* not updated, return the existing value, unless ext was