Skip to content

Commit

Permalink
Eliminate unused function arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
hadley committed Nov 7, 2024
1 parent c0c88f1 commit d4b0c63
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
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

0 comments on commit d4b0c63

Please sign in to comment.