]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-index: Small refactor in mail_cache_lookup_field()
authorSiavash Tavakoli <siavash.tavakoli@open-xchange.com>
Wed, 31 Mar 2021 16:28:46 +0000 (17:28 +0100)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Thu, 15 Apr 2021 07:06:27 +0000 (07:06 +0000)
Makes it easier to emit event in next commit regardless of code path.

src/lib-index/mail-cache-lookup.c

index c0695e4154bb731dc0cbf62ea12fbb0946fdced3..300c9e21c7d371c6629f56cfffa4472e685e1b80 100644 (file)
@@ -429,17 +429,17 @@ int mail_cache_lookup_field(struct mail_cache_view *view, buffer_t *dest_buf,
        mail_cache_lookup_iter_init(view, seq, &iter);
        field_def = &view->cache->fields[field_idx].field;
        if (field_def->type == MAIL_CACHE_FIELD_BITMASK) {
-               return mail_cache_lookup_bitmask(&iter, field_idx,
-                                                field_def->field_size,
-                                                dest_buf);
-       }
-
-       /* return the first one that's found. if there are multiple
-          they're all identical. */
-       while ((ret = mail_cache_lookup_iter_next(&iter, &field)) > 0) {
-               if (field.field_idx == field_idx) {
-                       buffer_append(dest_buf, field.data, field.size);
-                       break;
+               ret = mail_cache_lookup_bitmask(&iter, field_idx,
+                                               field_def->field_size,
+                                               dest_buf);
+       } else {
+               /* return the first one that's found. if there are multiple
+                  they're all identical. */
+               while ((ret = mail_cache_lookup_iter_next(&iter, &field)) > 0) {
+                       if (field.field_idx == field_idx) {
+                               buffer_append(dest_buf, field.data, field.size);
+                               break;
+                       }
                }
        }
        return ret;