代码拉取完成,页面将自动刷新
From 23915d6eff1ba63c5a9967a519879225312ead01 Mon Sep 17 00:00:00 2001
From: nocjj <[email protected]>
Date: Mon, 15 Mar 2021 20:03:18 +0800
Subject: [PATCH] performance: change memset location
There is no need to clear all mem in add_domains, beacause memcpy will
write the front section. We only need to clear the mem in the end, which
will improve the performance.
Signed-off-by: nocjj <[email protected]>
---
src/domain.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/domain.c b/src/domain.c
index b8c527a..977cabe 100644
--- a/src/domain.c
+++ b/src/domain.c
@@ -55,11 +55,12 @@ struct domain *add_domains(struct domain_list *list)
if (new_list == NULL) {
return NULL;
}
- memset(new_list, 0, sizeof(struct domain) * (list->num + 1));
memcpy(new_list, list->domains, sizeof(struct domain) * list->num);
free(list->domains);
list->domains = new_list;
list->num++;
+ memset(&(list->domains[list->num - 1]), 0, sizeof(struct domain));
+
return &(list->domains[list->num - 1]);
}
--
2.27.0
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。