提交 18eb727f 编写于 作者: J Ján Tomko

Simplify virNodeCountThreadSiblings

Use a for loop instead of while.

Do not opencode c_isxdigit and virHexToBin.
上级 e37bcbd9
......@@ -361,15 +361,9 @@ virNodeCountThreadSiblings(const char *dir, unsigned int cpu)
if (virFileReadAll(path, SYSFS_THREAD_SIBLINGS_LIST_LENGTH_MAX, &str) < 0)
goto cleanup;
i = 0;
while (str[i] != '\0') {
if (c_isdigit(str[i]))
ret += count_one_bits(str[i] - '0');
else if (str[i] >= 'A' && str[i] <= 'F')
ret += count_one_bits(str[i] - 'A' + 10);
else if (str[i] >= 'a' && str[i] <= 'f')
ret += count_one_bits(str[i] - 'a' + 10);
i++;
for (i = 0; str[i] != '\0'; i++) {
if (c_isxdigit(str[i]))
ret += count_one_bits(virHexToBin(str[i]));
}
cleanup:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册