]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
auth: auth-cache - Refactor auth_cache_parse_key_and_fields()
authorAki Tuomi <aki.tuomi@open-xchange.com>
Wed, 30 Jul 2025 06:42:20 +0000 (09:42 +0300)
committertimo.sirainen <timo.sirainen@open-xchange.com>
Fri, 1 Aug 2025 08:18:11 +0000 (08:18 +0000)
Call auth_cache_parse_key_exclude() at the function end,
simplifies next commit.

src/auth/auth-cache.c

index 360ad8b3f62a6367d67009a1645c303007f7f521..3ccd45ff4b99cd3d0973357727c73d6a3a5b9ef5 100644 (file)
@@ -129,20 +129,18 @@ char *auth_cache_parse_key_and_fields(pool_t pool, const char *query,
                                      const ARRAY_TYPE(const_string) *fields,
                                      const char *exclude_driver)
 {
-       if (array_is_empty(fields))
-               return auth_cache_parse_key_exclude(pool, query, exclude_driver);
-
-       string_t *full_query = t_str_new(128);
-       str_append(full_query, query);
-
-       unsigned int i, count;
-       const char *const *str = array_get(fields, &count);
-       for (i = 0; i < count; i += 2) {
-               str_append_c(full_query, '\t');
-               str_append(full_query, str[i + 1]);
+       if (!array_is_empty(fields)) {
+               unsigned int i, count;
+               const char *const *str = array_get(fields, &count);
+               string_t *full_query = t_str_new(128);
+               str_append(full_query, query);
+               for (i = 0; i < count; i += 2) {
+                       str_append_c(full_query, '\t');
+                       str_append(full_query, str[i + 1]);
+               }
+               query = str_c(full_query);
        }
-       return auth_cache_parse_key_exclude(pool, str_c(full_query),
-                                           exclude_driver);
+       return auth_cache_parse_key_exclude(pool, query, exclude_driver);
 }
 
 static void