From acb798786b04a4a917477d955e479a12f79e0f31 Mon Sep 17 00:00:00 2001 From: Maximilian Girlich Date: Mon, 16 Oct 2023 13:15:42 +0000 Subject: [PATCH 1/3] Improve performance of tags functions --- R/tags.R | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/R/tags.R b/R/tags.R index e35691bb..e60cacc6 100644 --- a/R/tags.R +++ b/R/tags.R @@ -170,7 +170,12 @@ nullOrEmpty <- function(x) { # Given a vector or list, drop all the NULL or length-0 items in it dropNullsOrEmpty <- function(x) { - x[!vapply(x, nullOrEmpty, FUN.VALUE=logical(1))] + ns <- lengths(x) == 0 + if (any(ns)) { + x <- x[!ns] + } + + x } isResolvedTag <- function(x) { @@ -674,7 +679,6 @@ tags <- lapply(known_tags, function(tagname) { new_function( args = exprs(... = , .noWS = NULL, .renderHook = NULL), expr({ - validateNoWS(.noWS) contents <- dots_list(...) tag(!!tagname, contents, .noWS = .noWS, .renderHook = .renderHook) }), @@ -800,7 +804,8 @@ tag <- function(`_tag_name`, varArgs, .noWS = NULL, .renderHook = NULL) { } # Return tag data structure - structure(st, class = "shiny.tag") + class(st) <- "shiny.tag" + st } isTagList <- function(x) { From 17f2ecf012bcc32482a9d214215b05508fbcc872 Mon Sep 17 00:00:00 2001 From: Maximilian Girlich Date: Tue, 17 Oct 2023 04:19:21 +0000 Subject: [PATCH 2/3] Bump R Version --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 1b3b6ce9..d0ee1ef6 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -20,7 +20,7 @@ URL: https://github.com/rstudio/htmltools, https://rstudio.github.io/htmltools/ BugReports: https://github.com/rstudio/htmltools/issues Depends: - R (>= 2.14.1) + R (>= 3.2.0) Imports: base64enc, digest, From e6366f5cf9eac480aff9b956142b4c6e6e075e46 Mon Sep 17 00:00:00 2001 From: Maximilian Girlich Date: Tue, 17 Oct 2023 04:21:21 +0000 Subject: [PATCH 3/3] Remove unnecessary `nullOrEmpty()` --- R/tags.R | 4 ---- 1 file changed, 4 deletions(-) diff --git a/R/tags.R b/R/tags.R index e60cacc6..b7f8404b 100644 --- a/R/tags.R +++ b/R/tags.R @@ -164,10 +164,6 @@ dropNulls <- function(x) { x[!vapply(x, is.null, FUN.VALUE=logical(1))] } -nullOrEmpty <- function(x) { - length(x) == 0 -} - # Given a vector or list, drop all the NULL or length-0 items in it dropNullsOrEmpty <- function(x) { ns <- lengths(x) == 0