Skip to content

Commit

Permalink
Sped up expression deparsing.
Browse files Browse the repository at this point in the history
  • Loading branch information
NicChr committed Aug 31, 2024
1 parent d17327f commit ae1d1d9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion R/dots.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ named_dots <- function(...){
dots
}
dot_expr_names <- function(...){
vapply(substitute(alist(...))[-1L], deparse1, "", USE.NAMES = FALSE)
vapply(substitute(alist(...))[-1L], deparse2, "", USE.NAMES = FALSE)
}
10 changes: 5 additions & 5 deletions R/utils.R
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#' @noRd

# Include this as it's not available in older versions of R
deparse1 <- function(expr, collapse = " ", width.cutoff = 500L, ...){
paste(deparse(expr, width.cutoff, ...), collapse = collapse)
# Like deparse1 but has a cutoff in case of massive strings
deparse2 <- function(expr, collapse = " ", width.cutoff = 500L, nlines = 5L, ...){
paste(deparse(expr, width.cutoff, nlines = nlines, ...), collapse = collapse)
}

is_integerable <- function(x){
Expand Down Expand Up @@ -38,12 +38,12 @@ list_as_df <- cpp_list_as_df

check_length <- function(x, n){
if (length(x) != n){
stop(paste(deparse1(substitute(x)), "must have length", n))
stop(paste(deparse2(substitute(x)), "must have length", n))
}
}
check_is_df <- function(x){
if (!inherits(x, "data.frame")){
stop(paste(deparse1(substitute(x)), "must be a data frame."))
stop(paste(deparse2(substitute(x)), "must be a data frame."))
}
}
df_add_cols <- function(data, cols){
Expand Down

0 comments on commit ae1d1d9

Please sign in to comment.