Commit 38a8ee9b authored by Radford Neal's avatar Radford Neal

more performance tweaks to eval and do_return

parent a0e24ea7
......@@ -1336,6 +1336,7 @@ extern0 Rboolean known_to_be_utf8 INI_as(FALSE);
# define StrToInternal Rf_StrToInternal
# define strmat2intmat Rf_strmat2intmat
# define substituteList Rf_substituteList
# define too_deep_error Rf_too_deep_error
# define tsConform Rf_tsConform
# define tspgets Rf_tspgets
# define type2symbol Rf_type2symbol
......@@ -1639,6 +1640,7 @@ SEXP R_subassign3_dflt(SEXP, SEXP, SEXP, SEXP);
#include <wchar.h>
/* main/util.c */
R_NORETURN void too_deep_error(void);
R_NORETURN void UNIMPLEMENTED_TYPE(const char *s, SEXP x);
R_NORETURN void UNIMPLEMENTED_TYPEt(const char *s, SEXPTYPE t);
R_NORETURN void dotdotdot_error(void);
......
......@@ -443,11 +443,8 @@ SEXP evalv (SEXP e, SEXP rho, int variant)
R_EvalDepth += 1;
if (R_EvalDepth > R_Expressions) {
R_Expressions = R_Expressions_keep + 500;
errorcall (R_NilValue /* avoids deparsing call in the error handler */,
_("evaluation nested too deeply: infinite recursion / options(expressions=)?"));
}
if (R_EvalDepth > R_Expressions)
too_deep_error();
/* Do evaluation as for fast eval macro. */
......@@ -1687,14 +1684,13 @@ static SEXP do_return(SEXP call, SEXP op, SEXP args, SEXP rho, int variant)
{
SEXP v;
if (args == R_NilValue) /* zero arguments provided */
v = R_NilValue;
else if (CDR(args) == R_NilValue) /* one argument */
v = evalv (CAR(args), rho, ! (variant & VARIANT_DIRECT_RETURN) ? 0
: VARIANT_PASS_ON(variant) & ~ VARIANT_NULL);
else
if (CDR(args) != R_NilValue)
errorcall(call, _("multi-argument returns are not permitted"));
v = evalv (CAR(args), /* relies on CDR(R_NilValue) being R_NilValue. */
rho, ! (variant & VARIANT_DIRECT_RETURN) ? 0
: VARIANT_PASS_ON(variant) & ~ VARIANT_NULL);
if (variant & VARIANT_DIRECT_RETURN) {
R_variant_result |= VARIANT_RTN_FLAG;
return v;
......
......@@ -679,6 +679,14 @@ void R_NORETURN UNIMPLEMENTED_TYPE (const char *s, SEXP x)
/* -------------------------------------------------------------------------- */
R_NORETURN void too_deep_error(void)
{
R_Expressions = R_Expressions_keep + 500;
errorcall (R_NilValue /* avoids deparsing call in the error handler */,
_("evaluation nested too deeply: infinite recursion / options(expressions=)?"
));
}
R_NORETURN void attribute_hidden dotdotdot_error(void)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment