collapse_passthru_fun: Remove All Intermediate Levels of a Passthrough

Description Usage Arguments Details Value

Description

Motivated by functions like `try` and `tryCatch` that have multiple layers of internal calls but then eventually go to evaluate user code. The idea here is to collapse all those intermediate levels so they don't clutter the profile tree.

Usage

1
collapse_passthru_fun(x, passthru)

Arguments

x

a treeprof object

passthru

a `passthru_fun` object

Details

Most of these functions seem to have a common pattern: there is the function itself that is called, and then at some point, one final function is called before the user code is evaluated. We capture this by looking for the initial function, and then within the children of that function, look for the final function subject to the condition that the final function is not followed by a disallowed function. This last condition is necessary because some functions like `tryCatch` call themselves in order to register multiple handlers so we would otherwise think we have exited the function when in reality we haven't.

Clearly this isn't completely fool proof, especially if someone writes a function with the same name as some of these base passthru functions.

Value

a modified treeprof object


brodieG/treeprof documentation built on May 13, 2019, 7:47 a.m.