Skip to content

Commit

Permalink
Fix performance impact (get0) R>=3.2
Browse files Browse the repository at this point in the history
  • Loading branch information
zeehio committed Apr 17, 2023
1 parent 6d29037 commit 4dba01a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ License: MIT + file LICENSE
URL: https://r6.r-lib.org, https://github.com/r-lib/R6/
BugReports: https://github.com/r-lib/R6/issues
Depends:
R (>= 3.0)
R (>= 3.2)
Suggests:
lobstr,
testthat (>= 3.0.0)
Expand Down
8 changes: 3 additions & 5 deletions R/clone.R
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,9 @@ generator_funs$clone_method <- function(deep = FALSE) {
# fields that are R6 objects.
deep_clone <- function(name, value) {
# Check if it's an R6 object.
if (
is.environment(value) &&
".__enclos_env__" %in% ls(value, all.names = TRUE) &&
!is.null(get(".__enclos_env__", value))
) {
is_r6_object <- is.environment(value) &&
!is.null(get0(".__enclos_env__", value, inherits = FALSE))
if (is_r6_object) {
return(value$clone(deep = TRUE))
}
value
Expand Down

0 comments on commit 4dba01a

Please sign in to comment.