Commit e79bcf8b authored by Adam Langley's avatar Adam Langley

runtime: shift the index for the sort by one.

Makes the code look cleaner, even if it's a little harder to figure
out from the sort invariants.

R=rsc
CC=golang-dev
https://golang.org/cl/165061
parent 0b5cc316
...@@ -660,12 +660,8 @@ runtime·selectgo(Select *sel) ...@@ -660,12 +660,8 @@ runtime·selectgo(Select *sel)
// sort the cases by Hchan address to get the locking order. // sort the cases by Hchan address to get the locking order.
for(i=1; i<sel->ncase; i++) { for(i=1; i<sel->ncase; i++) {
cas = sel->scase[i]; cas = sel->scase[i];
for(j=i-1; j<i && sel->scase[j]->chan >= cas->chan; j--) for(j=i; j>0 && sel->scase[j-1]->chan >= cas->chan; j--)
sel->scase[j+1] = sel->scase[j]; sel->scase[j] = sel->scase[j-1];
// careful: j might be (unsigned)-1
// 6c trips on sel->scase[j+1] in that case by rewriting it to
// sel->scase[j] + 8.
j++;
sel->scase[j] = cas; sel->scase[j] = cas;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment