Fewer name copies in step

Part of an refactor to eliminate intermediate copies in qpzone_find.
This commit is contained in:
Alessio Podda 2025-12-14 14:21:52 +01:00 committed by Ondřej Surý
parent d0e04ed0e7
commit 33dfd3c0ce
No known key found for this signature in database
GPG key ID: 2820F37E873DEA41

View file

@ -2642,16 +2642,13 @@ typedef enum { FORWARD, BACK } direction_t;
static bool
step(qpz_search_t *search, dns_qpiter_t *it, direction_t direction,
dns_name_t *nextname) {
dns_fixedname_t fnodename;
dns_name_t *nodename = dns_fixedname_initname(&fnodename);
qpznode_t *node = NULL;
qpznode_t *node = NULL, *previous_node = NULL;
isc_result_t result = ISC_R_SUCCESS;
result = dns_qpiter_current(it, (void **)&node, NULL);
if (result == ISC_R_SUCCESS) {
dns_name_copy(&node->name, nodename);
}
while (result == ISC_R_SUCCESS) {
previous_node = node;
isc_rwlock_t *nlock = qpzone_get_lock(node);
isc_rwlocktype_t nlocktype = isc_rwlocktype_none;
dns_vecheader_t *found = NULL;
@ -2670,13 +2667,11 @@ step(qpz_search_t *search, dns_qpiter_t *it, direction_t direction,
} else {
result = dns_qpiter_prev(it, (void **)&node, NULL);
}
if (result == ISC_R_SUCCESS) {
dns_name_copy(&node->name, nodename);
}
};
if (result == ISC_R_SUCCESS) {
if (nextname != NULL) {
dns_name_copy(nodename, nextname);
if (previous_node != NULL) {
dns_name_copy(&previous_node->name, nextname);
}
return true;
}