Skip to content

Commit

Permalink
Reverting extraneous
Browse files Browse the repository at this point in the history
  • Loading branch information
hadley committed Sep 16, 2024
1 parent a98537f commit 44f00af
Showing 1 changed file with 13 additions and 21 deletions.
34 changes: 13 additions & 21 deletions R/profvis.R
Original file line number Diff line number Diff line change
Expand Up @@ -172,12 +172,10 @@ profvis <- function(expr = NULL,
on.exit(unlink(prof_output), add = TRUE)
}

# Use unique name so we can easily find in trim_suffix()
`__profvis_execute__` <- new_function(list(), expr_q, env)

repeat {
# Work around https://github.com/r-lib/rlang/issues/1749
# eval(substitute(delayedAssign("expr", expr_q, eval.env = env)))

inject(Rprof(prof_output, !!!rprof_args))
cnd <- with_profvis_handlers(`__profvis_execute__`())
Rprof(NULL)
Expand All @@ -199,10 +197,6 @@ profvis <- function(expr = NULL,
lines <- readLines(prof_output)
}

if (!is.character(lines)) {
str(lines)
}

message <- parse_rprof_lines(lines, expr_source)
message$prof_output <- prof_output

Expand Down Expand Up @@ -240,20 +234,18 @@ prof_matches <- function(lines, rerun) {
}

with_profvis_handlers <- function(expr) {
# Use unique name so we can easily find in trim_suffix()


tryCatch(
expr,
error = function(cnd) {
message("profvis: code exited with error:\n", cnd$message, "\n")
cnd
},
interrupt = function(cnd) {
message("profvis: interrupt received.")
cnd
}
)
tryCatch({
expr
NULL
},
error = function(cnd) {
message("profvis: code exited with error:\n", cnd$message, "\n")
cnd
},
interrupt = function(cnd) {
message("profvis: interrupt received.")
cnd
})
}

trim_suffix <- function(lines) {
Expand Down

0 comments on commit 44f00af

Please sign in to comment.