Skip to content

Commit

Permalink
avoid unnecessary allocation
Browse files Browse the repository at this point in the history
  • Loading branch information
t-kalinowski committed Oct 31, 2024
1 parent eba69a0 commit e0e3f0a
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions src/method-dispatch.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,9 @@ SEXP method_(SEXP generic, SEXP signature, SEXP envir, SEXP error_) {
Rf_error("Corrupt S7_generic: @methods isn't an environment");
}

Rboolean error = Rf_asLogical(error_);
SEXP m = method_rec(table, signature, 0);

if (error && m == R_NilValue) {
if (m == R_NilValue && Rf_asLogical(error_)) {
S7_method_lookup_error(generic, envir);
}

Expand Down Expand Up @@ -254,9 +253,7 @@ SEXP method_call_(SEXP call_, SEXP op_, SEXP args_, SEXP env_) {
}

// Now that we have all the classes, we can look up what method to call
SEXP error_if_not_found = PROTECT(Rf_ScalarLogical(1));
++n_protect;
SEXP m = method_(generic, dispatch_classes, envir, error_if_not_found);
SEXP m = method_(generic, dispatch_classes, envir, R_TRUE);
SETCAR(mcall, m);

SEXP out = Rf_eval(mcall, envir);
Expand Down

0 comments on commit e0e3f0a

Please sign in to comment.