Skip to content

Commit

Permalink
only load RcppSimdJson if used
Browse files Browse the repository at this point in the history
  • Loading branch information
shikokuchuo committed Sep 12, 2024
1 parent 8f40766 commit 55c8c61
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 3 deletions.
1 change: 0 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ export(strat)
export(stratcombine)
export(tradingDays)
export(xts_df)
importFrom(RcppSimdJson,is_valid_json)
importFrom(ggplot2,"%+replace%")
importFrom(ggplot2,GeomCol)
importFrom(ggplot2,GeomLine)
Expand Down
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

* `oanda_studio()` adds option 'multi.session' to facilitate multiple sessions to be used with the Shiny app (for example more than one browser page).

#### Updates:

* Optimizes package load efficiency with `mirai` and `RcppSimdJson` only loaded the first time they are used.

# ichimoku 1.5.4

#### Updates:
Expand Down
2 changes: 1 addition & 1 deletion R/ichimoku-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@
#' scale_x_continuous scale_y_continuous Stat StatIdentity theme theme_grey
#' %+replace%
#' @importFrom nanonext ncurl
#' @importFrom RcppSimdJson is_valid_json
#' @importFrom shiny checkboxInput column downloadButton downloadHandler HTML
#' fillPage fluidPage fluidRow hoverOpts invalidateLater isolate
#' numericInput observeEvent plotOutput reactive reactiveVal renderPlot
Expand Down Expand Up @@ -117,6 +116,7 @@
if (i %in% c(1:3, 11:13)) Sys.sleep(0.03) else Sys.sleep(0.08)
}
cat("\n")
RcppSimdJson::is_valid_json("")
invisible(quote(expr=))
}

Expand Down
10 changes: 9 additions & 1 deletion src/shikokuchuo.c
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,14 @@ SEXP _naomit(SEXP x) {

// imports from the package 'RcppSimdJson'
SEXP _deserialize_json(SEXP json, SEXP query) {
if (jsofun == NULL) {
SEXP str, call;
PROTECT(str = Rf_mkString("RcppSimdJson"));
PROTECT(call = Rf_lang2(Rf_install("loadNamespace"), str));
Rf_eval(call, R_BaseEnv);
UNPROTECT(2);
jsofun = (SEXP (*)(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP)) R_GetCCallable("RcppSimdJson", "_RcppSimdJson_.deserialize_json");
}
return jsofun(json, query, R_NilValue, R_NilValue, R_NilValue, ichimoku_false, R_NilValue, ichimoku_false, R_NilValue, ichimoku_int_three, ichimoku_int_zero, ichimoku_int_zero);
}

Expand All @@ -352,7 +360,7 @@ static void RegisterSymbols(void) {
ichimoku_PeriodicitySymbol = Rf_install("periodicity");
ichimoku_TickerSymbol = Rf_install("ticker");
naofun = (SEXP (*)(SEXP)) R_GetCCallable("xts", "na_omit_xts");
jsofun = (SEXP (*)(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP)) R_GetCCallable("RcppSimdJson", "_RcppSimdJson_.deserialize_json");
jsofun = NULL;
}

static void PreserveObjects(void) {
Expand Down

0 comments on commit 55c8c61

Please sign in to comment.