Skip to content

Commit c17f2f2

Browse files
author
maechler
committed
asBool() logic (of unused code)
git-svn-id: https://svn.r-project.org/R/trunk@88249 00db46b3-68df-0310-9c12-caf00c1e9a41
1 parent 156bfca commit c17f2f2

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

src/library/methods/R/methodsTable.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1103,7 +1103,7 @@
11031103
cat("\n", file = printTo)
11041104
}
11051105

1106-
## temporary switch for tables
1106+
## temporary switch for tables (not used anywhere; for debugging)
11071107
useMTable <- function(onOff = NA)
11081108
.Call(C_R_set_method_dispatch, as.logical(onOff))
11091109

src/library/methods/src/methods_list_dispatch.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ static SEXP s_dot_Methods, s_skeleton, s_expression, s_function,
5454
s_missing, s_generic_dot_skeleton, s_subset_gets, s_element_gets,
5555
s_argument, s_allMethods, s_base;
5656
static SEXP R_FALSE, R_TRUE;
57-
static bool table_dispatch_on = 1;
57+
static bool table_dispatch_on = true;
5858

5959
/* precomputed skeletons for special primitive calls */
6060
static SEXP R_short_skeletons, R_empty_skeletons;
@@ -1172,11 +1172,13 @@ SEXP R_dispatchGeneric(SEXP fname, SEXP ev, SEXP fdef)
11721172

11731173
SEXP R_set_method_dispatch(SEXP onOff)
11741174
{
1175-
bool prev = table_dispatch_on, value = asBool(onOff);
1175+
int value = asLogical(onOff);
11761176
if(value == NA_LOGICAL) /* just return previous*/
1177-
value = prev;
1178-
table_dispatch_on = value;
1179-
if(value != prev) {
1177+
return ScalarLogical(table_dispatch_on);
1178+
// else
1179+
bool prev = table_dispatch_on;
1180+
table_dispatch_on = (bool)value;
1181+
if(table_dispatch_on != prev) {
11801182
R_set_standardGeneric_ptr(
11811183
(table_dispatch_on ? R_dispatchGeneric : R_standardGeneric),
11821184
Methods_Namespace);

0 commit comments

Comments
 (0)