From 1a8b114f90a5432e43e62b774b1ec02b92ed70f0 Mon Sep 17 00:00:00 2001 From: shikokuchuo <53399081+shikokuchuo@users.noreply.github.com> Date: Thu, 30 May 2024 08:23:03 +0100 Subject: [PATCH] strip out strcat --- NAMESPACE | 1 - R/daemons.R | 6 +++--- R/launchers.R | 2 +- R/mirai-package.R | 2 +- R/mirai.R | 4 ++-- R/parallel.R | 6 +----- man/register_cluster.Rd | 6 +----- tests/tests.R | 2 +- 8 files changed, 10 insertions(+), 19 deletions(-) diff --git a/NAMESPACE b/NAMESPACE index ca01d153e..3daab95b5 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -81,7 +81,6 @@ importFrom(nanonext,set_promise_context) importFrom(nanonext,socket) importFrom(nanonext,stat) importFrom(nanonext,stop_aio) -importFrom(nanonext,strcat) importFrom(nanonext,tls_config) importFrom(nanonext,unresolved) importFrom(nanonext,until) diff --git a/R/daemons.R b/R/daemons.R index b05097948..a80c1381a 100644 --- a/R/daemons.R +++ b/R/daemons.R @@ -300,7 +300,7 @@ daemons <- function(n, url = NULL, remote = NULL, dispatcher = TRUE, ..., dots <- parse_dots(...) output <- attr(dots, "output") urld <- local_url() - urlc <- strcat(urld, "c") + urlc <- sprintf("%s%s", urld, "c") sock <- req_socket(urld) sockc <- req_socket(urlc) launch_and_sync_daemon(sock, wa5(urld, dots, n, urlc, url), output, tls, pass) || stop(._[["sync_timeout"]]) @@ -348,7 +348,7 @@ daemons <- function(n, url = NULL, remote = NULL, dispatcher = TRUE, ..., if (dispatcher) { cv <- cv() sock <- req_socket(urld) - urlc <- strcat(urld, "c") + urlc <- sprintf("%s%s", urld, "c") sockc <- req_socket(urlc) launch_and_sync_daemon(sock, wa4(urld, dots, envir[["stream"]], n, urlc), output) || stop(._[["sync_timeout"]]) for (i in seq_len(n)) next_stream(envir) @@ -577,7 +577,7 @@ parse_dots <- function(...) { for (dot in dots) is.numeric(dot) || is.logical(dot) || stop(._[["wrong_dots"]]) dnames <- names(dots) - out <- strcat(",", paste(dnames, dots, sep = "=", collapse = ",")) + out <- sprintf(",%s", paste(dnames, dots, sep = "=", collapse = ",")) pos <- dnames == "output" any(pos) && as.logical(dots[pos])[1L] && return(`attr<-`(out, "output", "")) out diff --git a/R/launchers.R b/R/launchers.R index 00ed91381..e1b949d20 100644 --- a/R/launchers.R +++ b/R/launchers.R @@ -384,7 +384,7 @@ host_url <- function(ws = FALSE, tls = FALSE, port = 0) #' @rdname host_url #' @export #' -local_url <- function() strcat(.urlscheme, random(12L)) +local_url <- function() sprintf("%s%s", .urlscheme, random(12L)) #' @export #' diff --git a/R/mirai-package.R b/R/mirai-package.R index 89da3c67c..38a090616 100644 --- a/R/mirai-package.R +++ b/R/mirai-package.R @@ -45,7 +45,7 @@ #' @importFrom nanonext collect_aio collect_aio_ call_aio call_aio_ .context cv #' cv_value dial is_error_value listen lock mclock msleep next_config #' nng_error opt opt<- parse_url pipe_notify random reap recv recv_aio -#' request send set_promise_context socket stat stop_aio strcat tls_config +#' request send set_promise_context socket stat stop_aio tls_config #' unresolved until wait write_cert #' @importFrom stats rexp #' @importFrom utils .DollarNames diff --git a/R/mirai.R b/R/mirai.R index ab5c2ad38..7da7d717e 100644 --- a/R/mirai.R +++ b/R/mirai.R @@ -518,7 +518,7 @@ print.mirai <- function(x, ...) { #' print.miraiError <- function(x, ...) { - cat(strcat("'miraiError' chr ", x), file = stdout()) + cat(sprintf("'miraiError' chr %s", x), file = stdout()) invisible(x) } @@ -565,7 +565,7 @@ mk_mirai_error <- function(e, sc) { msg <- if (is.null(call) || call == "eval(expr = ._mirai_.[[\".expr\"]], envir = ._mirai_., enclos = NULL)") sprintf("Error: %s", .subset2(e, "message")) else sprintf("Error in %s: %s", call, .subset2(e, "message")) - cat(strcat(msg, "\n"), file = stderr()) + cat(sprintf("%s\n", msg), file = stderr()) idx <- which(as.logical(lapply(sc, identical, quote(eval(expr = ._mirai_.[[".expr"]], envir = ._mirai_., enclos = NULL))))) sc <- sc[(length(sc) - 1L):(idx + 1L)] if (sc[[1L]][[1L]] == ".handleSimpleError") diff --git a/R/parallel.R b/R/parallel.R index 432414397..88d5eff8e 100644 --- a/R/parallel.R +++ b/R/parallel.R @@ -215,11 +215,7 @@ print.miraiNode <- function(x, ...) { #' function relies on iis currently only available in R-devel (4.5). #' #' @examples -#' tryCatch( -#' -#' mirai::register_cluster() -#' -#' , error = identity) +#' tryCatch(mirai::register_cluster(), error = identity) #' #' @keywords internal #' @export diff --git a/man/register_cluster.Rd b/man/register_cluster.Rd index 4e3978099..895186ebb 100644 --- a/man/register_cluster.Rd +++ b/man/register_cluster.Rd @@ -22,11 +22,7 @@ The underlying implementation in the \pkg{parallel} package this function relies on iis currently only available in R-devel (4.5). } \examples{ -tryCatch( - -mirai::register_cluster() - -, error = identity) +tryCatch(mirai::register_cluster(), error = identity) } \keyword{internal} diff --git a/tests/tests.R b/tests/tests.R index c1ca5ac10..d7c32bb71 100644 --- a/tests/tests.R +++ b/tests/tests.R @@ -115,7 +115,7 @@ connection && .Platform[["OS.type"]] != "windows" && { mirai_map(1:3, rnorm, .args = list(mean = 20, 2), .compute = "ml")[.progress] }) nanotest(is.list(m) && length(m) == 3L && all(as.logical(lapply(m, is.numeric)))) - nanotestp(mp <- mirai_map(list(x = "a"), function(...) do(...), do = nanonext::strcat, .args = list("b"))) + nanotestp(mp <- mirai_map(list(x = "a"), function(...) do(...), do = function(x, y) sprintf("%s%s", x, y), .args = list("b"))) nanotesti(collect_mirai(mp)[["x"]], "ab") nanotesti(call_mirai(mp)[["x"]][["data"]], "ab") Sys.sleep(2.5)