Skip to content

Commit be927c1

Browse files
committed
perf(epi_slide): avoid arrange overhead per group
1 parent b31d466 commit be927c1

File tree

3 files changed

+4
-2
lines changed

3 files changed

+4
-2
lines changed

NAMESPACE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,5 +245,6 @@ importFrom(vctrs,vec_cast)
245245
importFrom(vctrs,vec_data)
246246
importFrom(vctrs,vec_duplicate_any)
247247
importFrom(vctrs,vec_equal)
248+
importFrom(vctrs,vec_order)
248249
importFrom(vctrs,vec_size)
249250
importFrom(vctrs,vec_sort)

R/epiprocess-package.R

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#' @importFrom tools toTitleCase
3030
#' @importFrom vctrs vec_data
3131
#' @importFrom vctrs vec_equal
32+
#' @importFrom vctrs vec_order
3233
#' @importFrom vctrs vec_sort
3334
## usethis namespace: end
3435
NULL

R/slide.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ epi_slide_one_group <- function(
354354
)
355355
)
356356
) %>%
357-
arrange(.data$time_value)
357+
`[`(vec_order(.$time_value), )
358358

359359
# If the data group does not contain any of the reference time values, return
360360
# the original .data_group without slide columns and let bind_rows at the end
@@ -902,7 +902,7 @@ epi_slide_opt <- function(
902902
.data_group,
903903
tibble(time_value = c(missing_times, pad_early_dates, pad_late_dates), .real = FALSE)
904904
) %>%
905-
arrange(.data$time_value)
905+
`[`(vec_order(.$time_value), )
906906

907907
if (f_from_package == "data.table") {
908908
# Grouping should ensure that we don't have duplicate time values.

0 commit comments

Comments
 (0)