dbScan: optimize addToList

Insert from back to maintain ~same order.
Avoid iterating entire list each time
in the common case where all PHAS==0
This commit is contained in:
Michael Davidsaver
2016-04-26 13:56:57 -04:00
committed by Ralph Lange
parent b392c1ca7d
commit 56d5a59356

View File

@@ -940,9 +940,9 @@ static void addToList(struct dbCommon *precord, scan_list *psl)
pse->precord = precord;
}
pse->pscan_list = psl;
ptemp = (scan_element *)ellFirst(&psl->list);
ptemp = (scan_element *)ellLast(&psl->list);
while (ptemp) {
if (ptemp->precord->phas > precord->phas) {
if (ptemp->precord->phas <= precord->phas) {
ellInsert(&psl->list, ellPrevious(&ptemp->node), &pse->node);
break;
}