MCPcopy Create free account
hub / github.com/cogentcore/core / Update

Method Update

tree/plan.go:230–253  ·  view source on GitHub ↗

Update updates the children of the given [Node] in accordance with the [Plan].

(n Node)

Source from the content-addressed store, hash-verified

228
229// Update updates the children of the given [Node] in accordance with the [Plan].
230func (p *Plan) Update(n Node) {
231 if len(p.Children) == 0 && !p.EnforceEmpty {
232 return
233 }
234 pr := profile.Start("plan.Update")
235 plan.Update(&n.AsTree().Children, len(p.Children),
236 func(i int) string {
237 return p.Children[i].Name
238 }, func(name string, i int) Node {
239 item := p.Children[i]
240 child := item.New()
241 child.AsTree().SetName(item.Name)
242 return child
243 }, func(child Node, i int) {
244 SetParent(child, n)
245 for _, f := range p.Children[i].Init {
246 f(child)
247 }
248 }, func(child Node) {
249 child.Destroy()
250 },
251 )
252 pr.End()
253}

Callers 4

BenchmarkUpdatePlanFunction · 0.95
moveToOverflowMethod · 0.95
overflowMenuMethod · 0.95
UpdateFromMakeMethod · 0.95

Calls 8

StartFunction · 0.92
UpdateFunction · 0.92
SetParentFunction · 0.85
AsTreeMethod · 0.65
NewMethod · 0.65
SetNameMethod · 0.65
DestroyMethod · 0.65
EndMethod · 0.45

Tested by 1

BenchmarkUpdatePlanFunction · 0.76