Skip to content

R_check_class_etc(x, valid) is "slow" when 'valid' contains class(x)

1 message · Mikael Jagan

#
R_check_class_etc(x, valid) spends a nontrivial amount of time finding
an environment 'rho' containing the definition of class(x), evaluating
(in R, not C) methods::.classEnv(class(x)).

It then returns the result of R_check_class_and_super(x, valid, rho).
But R_check_class_and_super() does not use 'rho' at all in the trivial
case where class(x) is found in 'valid'.

My feeling is that this can be improved.  I am happy to contribute a patch,
if it would be considered by R-core.

Mikael