mirror of
https://github.com/golang/go.git
synced 2025-05-23 00:11:26 +00:00
cmd/compile/internal/gc: clean up errcmp
Change-Id: Id07811a25bf4aa3ff834e7254a3dfb04522b2926 Reviewed-on: https://go-review.googlesource.com/14174 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Dave Cheney <dave@cheney.net>
This commit is contained in:
parent
4f48507d90
commit
4c96e7b79b
@ -59,26 +59,21 @@ func adderr(line int, format string, args ...interface{}) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// errcmp sorts errors by line, then seq, then message.
|
||||||
type errcmp []Error
|
type errcmp []Error
|
||||||
|
|
||||||
func (x errcmp) Len() int {
|
func (x errcmp) Len() int { return len(x) }
|
||||||
return len(x)
|
func (x errcmp) Swap(i, j int) { x[i], x[j] = x[j], x[i] }
|
||||||
}
|
|
||||||
|
|
||||||
func (x errcmp) Swap(i, j int) {
|
|
||||||
x[i], x[j] = x[j], x[i]
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x errcmp) Less(i, j int) bool {
|
func (x errcmp) Less(i, j int) bool {
|
||||||
a := &x[i]
|
a := &x[i]
|
||||||
b := &x[j]
|
b := &x[j]
|
||||||
if a.lineno != b.lineno {
|
if a.lineno != b.lineno {
|
||||||
return a.lineno-b.lineno < 0
|
return a.lineno < b.lineno
|
||||||
}
|
}
|
||||||
if a.seq != b.seq {
|
if a.seq != b.seq {
|
||||||
return a.seq-b.seq < 0
|
return a.seq < b.seq
|
||||||
}
|
}
|
||||||
return stringsCompare(a.msg, b.msg) < 0
|
return a.msg < b.msg
|
||||||
}
|
}
|
||||||
|
|
||||||
func Flusherrors() {
|
func Flusherrors() {
|
||||||
@ -86,7 +81,7 @@ func Flusherrors() {
|
|||||||
if len(errors) == 0 {
|
if len(errors) == 0 {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
sort.Sort(errcmp(errors[:len(errors)]))
|
sort.Sort(errcmp(errors))
|
||||||
for i := 0; i < len(errors); i++ {
|
for i := 0; i < len(errors); i++ {
|
||||||
if i == 0 || errors[i].msg != errors[i-1].msg {
|
if i == 0 || errors[i].msg != errors[i-1].msg {
|
||||||
fmt.Printf("%s", errors[i].msg)
|
fmt.Printf("%s", errors[i].msg)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user