idmap_cache: Use an fstring instead of talloc_asprintf
authorVolker Lendecke <vl@samba.org>
Wed, 4 Dec 2013 15:14:03 +0000 (15:14 +0000)
committerMichael Adam <obnox@samba.org>
Thu, 5 Dec 2013 00:10:25 +0000 (01:10 +0100)
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 <vl@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
source3/lib/idmap_cache.c

index ffd3c1955cdc723f80bc464cdf915983664ed9f5..4564bebfa36c5adce60f11571f7551922565c976 100644 (file)
@@ -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;
        }