Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Eliminate unused function arguments #582

Merged
merged 1 commit into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions R/replace.R
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ replacement <- function(name, env = as.environment(-1), target_value = get(name,
}

replace <- function(replacement) {
.Call(covr_reassign_function, replacement$name, replacement$env, replacement$target_value, replacement$new_value)
.Call(covr_reassign_function, replacement$target_value, replacement$new_value)
}

reset <- function(replacement) {
.Call(covr_reassign_function, replacement$name, replacement$env, replacement$target_value, replacement$orig_value)
.Call(covr_reassign_function, replacement$target_value, replacement$orig_value)
}
8 changes: 3 additions & 5 deletions src/reassign.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@
#include <Rdefines.h>
#include <stdlib.h> // for NULL

SEXP covr_reassign_function(SEXP name, SEXP env, SEXP old_fun, SEXP new_fun) {
if (TYPEOF(name) != SYMSXP) error("name must be a symbol");
if (TYPEOF(env) != ENVSXP) error("env must be an environment");
SEXP covr_reassign_function(SEXP old_fun, SEXP new_fun) {
if (TYPEOF(old_fun) != CLOSXP) error("old_fun must be a function");
if (TYPEOF(new_fun) != CLOSXP) error("new_fun must be a function");

Expand All @@ -23,11 +21,11 @@ SEXP covr_duplicate_(SEXP x) { return duplicate(x); }

/* .Call calls */
extern SEXP covr_duplicate_(SEXP);
extern SEXP covr_reassign_function(SEXP, SEXP, SEXP, SEXP);
extern SEXP covr_reassign_function(SEXP, SEXP);

static const R_CallMethodDef CallEntries[] = {
{"covr_duplicate_", (DL_FUNC)&covr_duplicate_, 1},
{"covr_reassign_function", (DL_FUNC)&covr_reassign_function, 4},
{"covr_reassign_function", (DL_FUNC)&covr_reassign_function, 2},
{NULL, NULL, 0}};

void R_init_covr(DllInfo *dll) {
Expand Down
Loading