copyFrom is the implementation of [NodeBase.CopyFrom].
(to, from Node)
| 669 | |
| 670 | // copyFrom is the implementation of [NodeBase.CopyFrom]. |
| 671 | func copyFrom(to, from Node) { |
| 672 | fc := from.AsTree().Children |
| 673 | if len(fc) == 0 { |
| 674 | to.AsTree().DeleteChildren() |
| 675 | } else { |
| 676 | p := make(TypePlan, len(fc)) |
| 677 | for i, c := range fc { |
| 678 | p[i].Type = c.AsTree().NodeType() |
| 679 | p[i].Name = c.AsTree().Name |
| 680 | } |
| 681 | UpdateSlice(&to.AsTree().Children, to, p) |
| 682 | } |
| 683 | |
| 684 | maps.Copy(to.AsTree().Properties, from.AsTree().Properties) |
| 685 | |
| 686 | to.AsTree().This.CopyFieldsFrom(from) |
| 687 | for i, kid := range to.AsTree().Children { |
| 688 | fmk := from.AsTree().Child(i) |
| 689 | copyFrom(kid, fmk) |
| 690 | } |
| 691 | } |
| 692 | |
| 693 | // Clone creates and returns a deep copy of the tree from this node down. |
| 694 | // Any pointers within the cloned tree will correctly point within the new |
no test coverage detected