From: Timo Sirainen Date: Sun, 24 Jan 2016 20:10:01 +0000 (+0200) Subject: auth: Avoid unnecessary work if passdb/userdb { override_fields, default_fields ... X-Git-Tag: 2.2.22.rc1~291 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=80e80d414f8fa748d2d10c40db423922968a11cc;p=thirdparty%2Fdovecot%2Fcore.git auth: Avoid unnecessary work if passdb/userdb { override_fields, default_fields } aren't set. --- diff --git a/src/auth/passdb-template.c b/src/auth/passdb-template.c index b3be9f9b55..6153af4111 100644 --- a/src/auth/passdb-template.c +++ b/src/auth/passdb-template.c @@ -43,6 +43,9 @@ void passdb_template_export(struct passdb_template *tmpl, const char *const *args, *value; unsigned int i, count; + if (passdb_template_is_empty(tmpl)) + return; + str = t_str_new(256); table = auth_request_get_var_expand_table(auth_request, NULL); @@ -79,3 +82,8 @@ bool passdb_template_remove(struct passdb_template *tmpl, } return FALSE; } + +bool passdb_template_is_empty(struct passdb_template *tmpl) +{ + return array_count(&tmpl->args) == 0; +} diff --git a/src/auth/passdb-template.h b/src/auth/passdb-template.h index e9d325f899..b4a1f00357 100644 --- a/src/auth/passdb-template.h +++ b/src/auth/passdb-template.h @@ -8,5 +8,6 @@ void passdb_template_export(struct passdb_template *tmpl, struct auth_request *auth_request); bool passdb_template_remove(struct passdb_template *tmpl, const char *key, const char **value_r); +bool passdb_template_is_empty(struct passdb_template *tmpl); #endif diff --git a/src/auth/userdb-template.c b/src/auth/userdb-template.c index 1bf2abb468..840f303b03 100644 --- a/src/auth/userdb-template.c +++ b/src/auth/userdb-template.c @@ -66,6 +66,9 @@ void userdb_template_export(struct userdb_template *tmpl, const char *const *args, *value; unsigned int i, count; + if (userdb_template_is_empty(tmpl)) + return; + str = t_str_new(256); table = auth_request_get_var_expand_table(auth_request, NULL);