In the AddFunction method, the given function's node is created, and then all other functions are searched to link them together if the the given function is related.
For common function calls, this creates an unnecessary number of redundant searches, because we're not checking if the node that was "created" actually already existed. If so, we already did the linking, so we can just skip that processing, which significantly reduces the operations the callgraph package needs to do to create the result.
func (cg *Graph) AddFunction(target *ssa.Function, allFns map[*ssa.Function]bool) error {
if _, ok := cg.Nodes[target]; ok {
return nil
}
targetNode := cg.CreateNode(target)
In the
AddFunction
method, the given function's node is created, and then all other functions are searched to link them together if the the given function is related.https://github.com/picatz/taint/blob/5d93683df8f992ef11dc052f2d2c53337a69c8b3/callgraph/callgraph.go#L176-L177
https://github.com/picatz/taint/blob/5d93683df8f992ef11dc052f2d2c53337a69c8b3/callgraph/callgraph.go#L235-L243
https://github.com/picatz/taint/blob/5d93683df8f992ef11dc052f2d2c53337a69c8b3/callgraph/callgraph.go#L189-L191
For common function calls, this creates an unnecessary number of redundant searches, because we're not checking if the node that was "created" actually already existed. If so, we already did the linking, so we can just skip that processing, which significantly reduces the operations the
callgraph
package needs to do to create the result.