| 621 | } |
| 622 | |
| 623 | func (p *Package) sortStructEmbeds() { |
| 624 | for { |
| 625 | nswap := 0 |
| 626 | for _, s := range p.structs { |
| 627 | emb := s.FirstEmbed() |
| 628 | if emb == nil { |
| 629 | continue |
| 630 | } |
| 631 | emss, ok := p.objs[emb.goname] |
| 632 | if !ok { |
| 633 | continue |
| 634 | } |
| 635 | if ems, isstru := emss.(*Struct); isstru { |
| 636 | if ems.idx > s.idx { |
| 637 | nswap++ |
| 638 | p.structs[s.idx], p.structs[ems.idx] = p.structs[ems.idx], p.structs[s.idx] |
| 639 | s.idx, ems.idx = ems.idx, s.idx |
| 640 | } |
| 641 | } |
| 642 | } |
| 643 | if nswap == 0 { |
| 644 | break |
| 645 | } |
| 646 | // fmt.Printf("%s nswap: %v\n", p.pkg.Path(), nswap) |
| 647 | } |
| 648 | } |