Avoid iterating name twice when constructing fctx->info

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.

(cherry picked from commit 49c40827f6)
This commit is contained in:
Diego Fronza 2020-11-28 18:07:29 -03:00 committed by Matthijs Mekking
parent 443e743156
commit f3bd27373d

View file

@ -4936,9 +4936,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'.
@ -4965,8 +4966,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");