Optimisation?
Posted: Thu May 29, 2008 8:19 pm
Couldn't the code:
arbiter.c @ line 115
be optimised to:
?
arbiter.c @ line 115
Code: Select all
for(int i=0; i<arb->numContacts; i++){
cpContact *old = &arb->contacts[i];
for(int j=0; j<numContacts; j++){
cpContact *new_contact = &contacts[j];
// This could trigger false possitives.
if(new_contact->hash == old->hash){
// Copy the persistant contact information.
new_contact->jnAcc = old->jnAcc;
new_contact->jtAcc = old->jtAcc;
}
}
}
Code: Select all
for(int i=0; i<arb->numContacts; i++){
cpContact *old = &arb->contacts[i];
for ( int j = i + 1; j<numContacts; j++){ // j = i + 1
cpContact *new_contact = &contacts[j];
// This could trigger false possitives.
if(new_contact->hash == old->hash){
// Copy the persistant contact information.
new_contact->jnAcc = old->jnAcc;
new_contact->jtAcc = old->jtAcc;
}
}
}