Skip to content

Commit

Permalink
Improve performance of tags functions
Browse files Browse the repository at this point in the history
  • Loading branch information
mgirlich committed Oct 16, 2023
1 parent 9436031 commit acb7987
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions R/tags.R
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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)
}),
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit acb7987

Please sign in to comment.