Skip to content

Commit 76ea830

Browse files
limit left join functionality for speed gain (3%)
1 parent 17bcb6d commit 76ea830

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

R/compat-dplyr.R

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,19 +52,20 @@ filter <- function(.data, ...) {
5252
subset(.data, ...)
5353
}
5454

55-
left_join <- function(x, y, by, ...) {
55+
left_join <- function(x, y, by) {
5656
if (rlang::is_named(by)) {
5757
by_x <- names(by)
5858
by_y <- unname(by)
5959
} else {
6060
by_x <- by_y <- by
6161
}
62-
res <- as_tibble(merge(x, y, by.x = by_x, by.y = by_y, all.x = TRUE, ...))
63-
res <- arrange(res, pos_id)
6462

63+
res <- merge(x, y, by.x = by_x, by.y = by_y, all.x = TRUE) %>%
64+
arrange_pos_id()
65+
res <- new_tibble(res, nrow = nrow(res))
6566
# dplyr::left_join set unknown list columns to NULL, merge sets them
6667
# to NA
67-
if (exists("child", res) && any(is.na(res$child))) {
68+
if (exists("child", res) && anyNA(res$child)) {
6869
res$child[is.na(res$child)] <- list(NULL)
6970
}
7071
res

0 commit comments

Comments
 (0)