aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Langley <agl@golang.org>2009-12-04 13:31:18 -0800
committerAdam Langley <agl@golang.org>2009-12-04 13:31:18 -0800
commite79bcf8bfdb35c0680db973fc65f2e8c60fb8331 (patch)
tree8bd19506dfc4dde7e16b5bb429e312ea21c801cc
parent0b5cc3169361981e221bb9f9b42226352979444f (diff)
downloadgo-e79bcf8bfdb35c0680db973fc65f2e8c60fb8331.tar.gz
go-e79bcf8bfdb35c0680db973fc65f2e8c60fb8331.zip
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
-rw-r--r--src/pkg/runtime/chan.c8
1 files changed, 2 insertions, 6 deletions
diff --git a/src/pkg/runtime/chan.c b/src/pkg/runtime/chan.c
index 1eef4b1cfa..633ff426e8 100644
--- a/src/pkg/runtime/chan.c
+++ b/src/pkg/runtime/chan.c
@@ -660,12 +660,8 @@ runtime·selectgo(Select *sel)
// sort the cases by Hchan address to get the locking order.
for(i=1; i<sel->ncase; i++) {
cas = sel->scase[i];
- for(j=i-1; j<i && sel->scase[j]->chan >= cas->chan; j--)
- sel->scase[j+1] = sel->scase[j];
- // 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++;
+ for(j=i; j>0 && sel->scase[j-1]->chan >= cas->chan; j--)
+ sel->scase[j] = sel->scase[j-1];
sel->scase[j] = cas;
}