merge merges two similar Signature, zapping out differences.
(r *Signature)
| 711 | |
| 712 | // merge merges two similar Signature, zapping out differences. |
| 713 | func (s *Signature) merge(r *Signature) *Signature { |
| 714 | min := s.SleepMin |
| 715 | if r.SleepMin < min { |
| 716 | min = r.SleepMin |
| 717 | } |
| 718 | max := s.SleepMax |
| 719 | if r.SleepMax > max { |
| 720 | max = r.SleepMax |
| 721 | } |
| 722 | return &Signature{ |
| 723 | State: s.State, // Drop right side. |
| 724 | CreatedBy: s.CreatedBy, // Drop right side. |
| 725 | SleepMin: min, |
| 726 | SleepMax: max, |
| 727 | Stack: *s.Stack.merge(&r.Stack), |
| 728 | Locked: s.Locked || r.Locked, // TODO(maruel): This is weirdo. |
| 729 | } |
| 730 | } |
| 731 | |
| 732 | // less compares two Signature, where the ones that are less are more |
| 733 | // important, so they come up front. A Signature with more private functions is |