]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Avoid iterating name twice when constructing fctx->info
authorDiego Fronza <diego@isc.org>
Sat, 28 Nov 2020 21:07:29 +0000 (18:07 -0300)
committerDiego Fronza <diego@isc.org>
Mon, 25 Jan 2021 13:47:14 +0000 (10:47 -0300)
This is a minor performance improvement, we store the result of the
first call to strlcat to use as an offset in the next call when
constructing fctx->info string.

lib/dns/resolver.c

index 447d85062b118efeebbc364f2df0ea9b5f38efd1..b0a0ec7820580ebebf5abe6c32367441a3efdf0c 100644 (file)
@@ -4850,9 +4850,10 @@ fctx_create(dns_resolver_t *res, const dns_name_t *name, dns_rdatatype_t type,
        isc_result_t iresult;
        isc_interval_t interval;
        unsigned int findoptions = 0;
-       char buf[DNS_NAME_FORMATSIZE + DNS_RDATATYPE_FORMATSIZE];
+       char buf[DNS_NAME_FORMATSIZE + DNS_RDATATYPE_FORMATSIZE + 1];
        char typebuf[DNS_RDATATYPE_FORMATSIZE];
        isc_mem_t *mctx;
+       size_t p;
 
        /*
         * Caller must be holding the lock for bucket number 'bucketnum'.
@@ -4879,8 +4880,8 @@ fctx_create(dns_resolver_t *res, const dns_name_t *name, dns_rdatatype_t type,
         */
        dns_name_format(name, buf, sizeof(buf));
        dns_rdatatype_format(type, typebuf, sizeof(typebuf));
-       strlcat(buf, "/", sizeof(buf));
-       strlcat(buf, typebuf, sizeof(buf));
+       p = strlcat(buf, "/", sizeof(buf));
+       strlcat(buf + p, typebuf, sizeof(buf));
        fctx->info = isc_mem_strdup(mctx, buf);
 
        FCTXTRACE("create");