MCPcopy Index your code
hub / github.com/maruel/panicparse / less

Method less

stack/stack.go:564–626  ·  view source on GitHub ↗

less compares two Stack, where the ones that are less are more important, so they come up front. A Stack with more private functions is 'less' so it is at the top. Inversely, a Stack with only public functions is 'more' so it is at the bottom.

(r *Stack)

Source from the content-addressed store, hash-verified

562// Inversely, a Stack with only public functions is 'more' so it is at the
563// bottom.
564func (s *Stack) less(r *Stack) bool {
565 lLoc := [lastLocation]int{}
566 rLoc := [lastLocation]int{}
567 lMain := 0
568 rMain := 0
569 for _, c := range s.Calls {
570 lLoc[c.Location]++
571 if c.Func.IsPkgMain {
572 lMain++
573 }
574 }
575 for _, s := range r.Calls {
576 rLoc[s.Location]++
577 if s.Func.IsPkgMain {
578 rMain++
579 }
580 }
581 if lMain > rMain {
582 return true
583 }
584 if lMain < rMain {
585 return false
586 }
587 for i := 1; i < int(lastLocation); i++ {
588 if lLoc[i] > rLoc[i] {
589 return true
590 }
591 if lLoc[i] < rLoc[i] {
592 return false
593 }
594 }
595 // Check unknown code type last.
596 if lLoc[LocationUnknown] > rLoc[LocationUnknown] {
597 return true
598 }
599 if lLoc[LocationUnknown] < rLoc[LocationUnknown] {
600 return false
601 }
602
603 // Stack lengths are the same and they are mostly of the same kind of location.
604 for x := range s.Calls {
605 if s.Calls[x].Func.Complete < r.Calls[x].Func.Complete {
606 return true
607 }
608 if s.Calls[x].Func.Complete > r.Calls[x].Func.Complete {
609 return false
610 }
611 if s.Calls[x].DirSrc < r.Calls[x].DirSrc {
612 return true
613 }
614 if s.Calls[x].DirSrc > r.Calls[x].DirSrc {
615 return false
616 }
617 if s.Calls[x].Line < r.Calls[x].Line {
618 return true
619 }
620 if s.Calls[x].Line > r.Calls[x].Line {
621 return false

Callers 3

TestSignature_LessFunction · 0.45
lessMethod · 0.45
AggregateMethod · 0.45

Calls

no outgoing calls

Tested by 1

TestSignature_LessFunction · 0.36