MCPcopy Create free account
hub / github.com/google/pprof / findOrAdd

Method findOrAdd

internal/report/report.go:367–383  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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.
367func (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.
386func printAssembly(w io.Writer, rpt *Report, obj plugin.ObjTool) error {

Callers 2

TestFunctionMapFunction · 0.80
printTopProtoFunction · 0.80

Calls

no outgoing calls

Tested by 1

TestFunctionMapFunction · 0.64