Skip to content

Commit 3d675a2

Browse files
committed
When doing case ranges, continue searching for the new insertion point from the previously inserted value, don't start over from the beginning of the list
1 parent 0e911d8 commit 3d675a2

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

source/compiler/sc3.c

+4-7
Original file line numberDiff line numberDiff line change
@@ -1713,15 +1713,12 @@ static int hier2(value *lval)
17131713
error(50); /* invalid range */
17141714
while (++val<=end) {
17151715
casecount++;
1716-
/* find the new insertion point */
1717-
for (csp=NULL, cse=caselist.first;
1718-
cse!=NULL && cse->value<val;
1719-
csp=cse, cse=cse->next)
1720-
/* nothing */;
1716+
csp=newval;
1717+
cse=newval->next;
17211718
if (cse!=NULL && cse->value==val)
17221719
error(40,val); /* duplicate "case" label */
1723-
assert(csp==NULL || csp->next==cse);
1724-
insert_constval(csp,cse,itoh(lbl_case),val,0);
1720+
assert(csp!=NULL && csp->next==cse);
1721+
newval=insert_constval(csp,cse,itoh(lbl_case),val,0);
17251722
} /* while */
17261723
} /* if */
17271724
} while (matchtoken(','));

0 commit comments

Comments
 (0)