mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-22 11:22:23 +00:00
Simplify virNodeCountThreadSiblings
Use a for loop instead of while. Do not opencode c_isxdigit and virHexToBin.
This commit is contained in:
parent
e37bcbd9b8
commit
18eb727fe9
@ -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:
|
||||
|
Loading…
x
Reference in New Issue
Block a user