From 89013af15aa45311510318b517de8986580f4e2f Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Wed, 4 Dec 2013 15:14:03 +0000 Subject: [PATCH] idmap_cache: Use an fstring instead of talloc_asprintf In a test doing one million uid2sid calls this brings down user CPU from 1.3 seconds to 0.9 seconds. And it saves a few code lines. Signed-off-by: Volker Lendecke Reviewed-by: Michael Adam --- source3/lib/idmap_cache.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/source3/lib/idmap_cache.c b/source3/lib/idmap_cache.c index ffd3c1955cd..4564bebfa36 100644 --- a/source3/lib/idmap_cache.c +++ b/source3/lib/idmap_cache.c @@ -200,17 +200,14 @@ bool idmap_cache_find_sid2gid(const struct dom_sid *sid, gid_t *pgid, bool idmap_cache_find_uid2sid(uid_t uid, struct dom_sid *sid, bool *expired) { - char *key; + fstring key; char *value; time_t timeout; bool ret = true; - key = talloc_asprintf(talloc_tos(), "IDMAP/UID2SID/%d", (int)uid); - if (key == NULL) { - return false; - } + fstr_sprintf(key, "IDMAP/UID2SID/%d", (int)uid); + ret = gencache_get(key, talloc_tos(), &value, &timeout); - TALLOC_FREE(key); if (!ret) { return false; } @@ -237,17 +234,14 @@ bool idmap_cache_find_uid2sid(uid_t uid, struct dom_sid *sid, bool *expired) bool idmap_cache_find_gid2sid(gid_t gid, struct dom_sid *sid, bool *expired) { - char *key; + fstring key; char *value; time_t timeout; bool ret = true; - key = talloc_asprintf(talloc_tos(), "IDMAP/GID2SID/%d", (int)gid); - if (key == NULL) { - return false; - } + fstr_sprintf(key, "IDMAP/GID2SID/%d", (int)gid); + ret = gencache_get(key, talloc_tos(), &value, &timeout); - TALLOC_FREE(key); if (!ret) { return false; } -- 2.11.4.GIT