Skip to content

Commit

Permalink
Drop purrr dependency (#158)
Browse files Browse the repository at this point in the history
  • Loading branch information
hadley authored Jul 3, 2024
1 parent cd3c679 commit 9955c74
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 18 deletions.
1 change: 0 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ Depends:
R (>= 3.0)
Imports:
htmlwidgets (>= 0.3.2),
purrr,
rlang (>= 0.4.9),
stringr,
vctrs
Expand Down
5 changes: 0 additions & 5 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,5 @@ export(renderProfvis)
import(htmlwidgets)
import(rlang)
import(stringr)
importFrom(purrr,map)
importFrom(purrr,map2)
importFrom(purrr,map_int)
importFrom(purrr,simplify)
importFrom(purrr,transpose)
importFrom(utils,Rprof)
useDynLib(profvis, .registration = TRUE, .fixes = "c_")
1 change: 0 additions & 1 deletion R/aaa.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#' @import rlang
#' @importFrom purrr map map_int map2 transpose simplify
NULL

.onLoad <- function(...) {
Expand Down
18 changes: 7 additions & 11 deletions R/parse.R
Original file line number Diff line number Diff line change
Expand Up @@ -321,18 +321,14 @@ prof_sort <- function(prof) {
# stack.
prof_split <- vctrs::vec_split(prof, prof$time)$val

max_depth <- max(map_int(prof_split, nrow))
max_depth <- max(vapply(prof_split, nrow, integer(1)))
n_samples <- length(prof_split)

# Extract labels (function names for the stack frames) and pad
# them with missing values so they are of equal lengths
# Extract labels (function names for the stack frames) and pad with NAs
# so we can easily make a data frame
pad <- function(x) x[seq_len(max_depth)]
stacks <- map(prof_split, function(x) pad(rev(x$label)))

# Transpose into a data frame. The (unnamed) columns represent
# increasing depths in the stacks.
stacks <- map(transpose(stacks), simplify)
stacks <- vctrs::data_frame(!!!stacks, .name_repair = "minimal")
stacks <- lapply(prof_split, function(x) pad(rev(x$label)))
stacks <- as.data.frame(do.call(rbind, stacks))

# Reorder the profile data according to the sort key of the
# transposed stacks
Expand All @@ -342,15 +338,15 @@ prof_sort <- function(prof) {

# Now that stacks are in alphabetical order we sort them again by
# contiguous run
runs <- map(stacks, function(stack) {
runs <- lapply(stacks, function(stack) {
times <- vctrs::vec_unrep(stack)$times
rep(rev(order(times)), times)
})
runs <- vctrs::data_frame(!!!runs, .name_repair = "minimal")
prof_split <- prof_split[vctrs::vec_order(runs)]

# Assign an increasing `time` sequence in each split
prof_split <- map2(seq_len(n_samples), prof_split, function(n, split) {
prof_split <- Map(seq_len(n_samples), prof_split, f = function(n, split) {
split$time <- n
split
})
Expand Down

0 comments on commit 9955c74

Please sign in to comment.