findOrAdd takes a node representing a function, adds the function represented by the node to the map if the function is not already present, and returns the function the node represents. This also returns a boolean, which is true if the function was added and false otherwise.
(ni graph.NodeInfo)
| 365 | // and returns the function the node represents. This also returns a boolean, |
| 366 | // which is true if the function was added and false otherwise. |
| 367 | func (fm functionMap) findOrAdd(ni graph.NodeInfo) (*profile.Function, bool) { |
| 368 | fName := fmt.Sprintf("%q%q%q%d", ni.Name, ni.OrigName, ni.File, ni.StartLine) |
| 369 | |
| 370 | if f := fm[fName]; f != nil { |
| 371 | return f, false |
| 372 | } |
| 373 | |
| 374 | f := &profile.Function{ |
| 375 | ID: uint64(len(fm) + 1), |
| 376 | Name: ni.Name, |
| 377 | SystemName: ni.OrigName, |
| 378 | Filename: ni.File, |
| 379 | StartLine: int64(ni.StartLine), |
| 380 | } |
| 381 | fm[fName] = f |
| 382 | return f, true |
| 383 | } |
| 384 | |
| 385 | // printAssembly prints an annotated assembly listing. |
| 386 | func printAssembly(w io.Writer, rpt *Report, obj plugin.ObjTool) error { |
no outgoing calls