Skip to content

Commit 3e0d0da

Browse files
tjk213Explorer09
andauthored
optimize coreIndex enumeration
Co-authored-by: Kang-Che Sung (宋岡哲) <Explorer09@gmail.com>
1 parent 0724863 commit 3e0d0da

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

linux/LinuxMachine.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -740,9 +740,10 @@ static void LinuxMachine_computeThreadIndices(LinuxMachine* this) {
740740
enumerated in an alternative order, or both. */
741741
for (size_t i = 1; i <= super->existingCPUs; i++) {
742742
int coreIndex = 0;
743-
for (size_t j = 1; j < i; j++) {
743+
for (size_t j = i - 1; j >= 1; j--) {
744744
if (cpus[i].threadIndex == cpus[j].threadIndex) {
745-
coreIndex++;
745+
cpus[i].coreIndex = cpus[j].coreIndex + 1;
746+
break;
746747
}
747748
}
748749
cpus[i].coreIndex = coreIndex;

0 commit comments

Comments
 (0)