From: Paul Eggert Date: Sun, 27 Mar 2016 02:24:25 +0000 (-0700) Subject: func-arity minor improvements X-Git-Url: https://code.delx.au/gnu-emacs/commitdiff_plain/bc9cc21d34ae71dc38bd20f224c4b3ac073bcb50 func-arity minor improvements * src/bytecode.c (get_byte_code_arity): Omit unnecessary runtime test for integer argument, unless debugging. Use EMACS_INT for Emacs integers. * src/eval.c (Ffunc_arity): Omit unused locals. Avoid side effects in ‘if’ expr. (lambda_arity): Use bool for boolean, and EMACS_INT for Emacs ints. --- diff --git a/src/bytecode.c b/src/bytecode.c index 4ff15d2912..fb9f617b51 100644 --- a/src/bytecode.c +++ b/src/bytecode.c @@ -1991,18 +1991,14 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth, Lisp_Object get_byte_code_arity (Lisp_Object args_template) { - if (INTEGERP (args_template)) - { - ptrdiff_t at = XINT (args_template); - bool rest = (at & 128) != 0; - int mandatory = at & 127; - ptrdiff_t nonrest = at >> 8; - - return Fcons (make_number (mandatory), - rest ? Qmany : make_number (nonrest)); - } - else - error ("Unknown args template!"); + eassert (NATNUMP (args_template)); + EMACS_INT at = XINT (args_template); + bool rest = (at & 128) != 0; + int mandatory = at & 127; + EMACS_INT nonrest = at >> 8; + + return Fcons (make_number (mandatory), + rest ? Qmany : make_number (nonrest)); } void diff --git a/src/eval.c b/src/eval.c index 64a6655684..e90b077bfb 100644 --- a/src/eval.c +++ b/src/eval.c @@ -2946,7 +2946,6 @@ function with `&rest' args, or `unevalled' for a special form. */) Lisp_Object original; Lisp_Object funcar; Lisp_Object result; - short minargs, maxargs; original = function; @@ -2954,9 +2953,12 @@ function with `&rest' args, or `unevalled' for a special form. */) /* Optimize for no indirection. */ function = original; - if (SYMBOLP (function) && !NILP (function) - && (function = XSYMBOL (function)->function, SYMBOLP (function))) - function = indirect_function (function); + if (SYMBOLP (function) && !NILP (function)) + { + function = XSYMBOL (function)->function; + if (SYMBOLP (function)) + function = indirect_function (function); + } if (SUBRP (function)) result = Fsubr_arity (function); @@ -2989,9 +2991,7 @@ function with `&rest' args, or `unevalled' for a special form. */) static Lisp_Object lambda_arity (Lisp_Object fun) { - Lisp_Object val, syms_left, next; - ptrdiff_t minargs, maxargs; - bool optional; + Lisp_Object syms_left; if (CONSP (fun)) { @@ -3018,17 +3018,18 @@ lambda_arity (Lisp_Object fun) else emacs_abort (); - minargs = maxargs = optional = 0; + EMACS_INT minargs = 0, maxargs = 0; + bool optional = false; for (; CONSP (syms_left); syms_left = XCDR (syms_left)) { - next = XCAR (syms_left); + Lisp_Object next = XCAR (syms_left); if (!SYMBOLP (next)) xsignal1 (Qinvalid_function, fun); if (EQ (next, Qand_rest)) return Fcons (make_number (minargs), Qmany); else if (EQ (next, Qand_optional)) - optional = 1; + optional = true; else { if (!optional) @@ -3043,7 +3044,6 @@ lambda_arity (Lisp_Object fun) return Fcons (make_number (minargs), make_number (maxargs)); } - DEFUN ("fetch-bytecode", Ffetch_bytecode, Sfetch_bytecode, 1, 1, 0, doc: /* If byte-compiled OBJECT is lazy-loaded, fetch it now. */)