mirror of
https://github.com/rstudio/shiny.git
synced 2026-01-14 09:28:02 -05:00
Fix performance regression related to limiting deep call stack growth (#4214)
* Use less expensive version of getCallNames() just for hashing * Update R/conditions.R Co-authored-by: Carson Sievert <cpsievert1@gmail.com> --------- Co-authored-by: Carson Sievert <cpsievert1@gmail.com> Co-authored-by: Barret Schloerke <barret@rstudio.com>
This commit is contained in:
@@ -75,6 +75,18 @@ getCallNames <- function(calls) {
|
||||
})
|
||||
}
|
||||
|
||||
# A stripped down version of getCallNames() that intentionally avoids deparsing expressions.
|
||||
# Instead, it leaves expressions to be directly `rlang::hash()` (for de-duplication), which
|
||||
# is much faster than deparsing then hashing.
|
||||
getCallNamesForHash <- function(calls) {
|
||||
lapply(calls, function(call) {
|
||||
name <- call[[1L]]
|
||||
if (is.function(name)) return("<Anonymous>")
|
||||
if (typeof(name) == "promise") return("<Promise>")
|
||||
name
|
||||
})
|
||||
}
|
||||
|
||||
getLocs <- function(calls) {
|
||||
vapply(calls, function(call) {
|
||||
srcref <- attr(call, "srcref", exact = TRUE)
|
||||
@@ -144,7 +156,7 @@ getCallStackDigest <- function(callStack, warn = FALSE) {
|
||||
)
|
||||
}
|
||||
|
||||
rlang::hash(getCallNames(callStack))
|
||||
rlang::hash(getCallNamesForHash(callStack))
|
||||
}
|
||||
|
||||
saveCallStackDigest <- function(callStack) {
|
||||
|
||||
Reference in New Issue
Block a user