Skip to content

Simplify rFunctionExistsInModule source-module branch#81

Merged
vandenman merged 1 commit into
jasp-stats:masterfrom
JTPetter:cleanupFuncExist
May 29, 2026
Merged

Simplify rFunctionExistsInModule source-module branch#81
vandenman merged 1 commit into
jasp-stats:masterfrom
JTPetter:cleanupFuncExist

Conversation

@JTPetter
Copy link
Copy Markdown
Contributor

The source-module (else) branch of rFunctionExistsInModule sourced every
.R file in the module's R/ directory into a temporary environment on each
call, just to check whether one function is defined.

This replaces it with a namespace lookup via getFromNamespace, wrapped to
return TRUE/FALSE. Per-call resolution dropped ~10x locally (≈0.23s → ≈0.02s)
and avoids repeatedly parsing/evaluating module source.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Replaces the source-file sourcing approach in rFunctionExistsInModule()'s source-module branch with a namespace lookup via utils::getFromNamespace(), wrapped in a small function_exists() helper. This avoids parsing/evaluating every .R file in the module on each call (~10x speedup locally).

Changes:

  • Adds function_exists() helper that wraps utils::getFromNamespace() in tryCatch to return TRUE/FALSE.
  • Rewrites the source-module branch of rFunctionExistsInModule() to call function_exists(moduleName, funName) instead of sourcing all R/*.R files into a temp env.

@vandenman vandenman merged commit 1757612 into jasp-stats:master May 29, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants