perf: 删除无效代码;修改变量命名;减少内存分配

This commit is contained in:
luwenpeng
2023-11-23 16:52:06 +08:00
parent cbac7fea29
commit bda50d79af
19 changed files with 2937 additions and 472 deletions

View File

@@ -41,34 +41,14 @@ TEST(UTILS, SIDS)
struct sids src;
struct sids dst;
// set src
for (int i = 0; i < MR_SID_LIST_MAXLEN; i++)
{
src.elems[i] = i;
}
src.num = MR_SID_LIST_MAXLEN;
// copy src to dst
memset(&dst, 0, sizeof(struct sids));
sids_write_once(&dst, &src);
sids_copy(&dst, &src);
// check dst
EXPECT_TRUE(dst.num == src.num);
for (int i = 0; i < MR_SID_LIST_MAXLEN; i++)
{
EXPECT_TRUE(dst.elems[i] == i);
}
// update src
for (int i = 0; i < MR_SID_LIST_MAXLEN; i++)
{
src.elems[i] = i * 2;
}
// copy src to dst
sids_write_once(&dst, &src);
// check dst
EXPECT_TRUE(dst.num == src.num);
for (int i = 0; i < MR_SID_LIST_MAXLEN; i++)
{