Skip to content

Commit ca1d37c

Browse files
logic simplification
1 parent a72ae89 commit ca1d37c

File tree

1 file changed

+3
-11
lines changed

1 file changed

+3
-11
lines changed

src/jsTypeFactory.cc

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -379,29 +379,21 @@ bool callPyFunc(JSContext *cx, unsigned int argc, JS::Value *vp) {
379379
else {
380380
nNormalArgs = 1;
381381
PyObject *f = pyFunc;
382-
bool isMethod;
383382
if (PyMethod_Check(pyFunc)) {
384383
f = PyMethod_Function(pyFunc); // borrowed reference
385384
nNormalArgs -= 1; // don't include the implicit `self` of the method as an argument
386-
isMethod = true;
387-
} else {
388-
isMethod = false;
389-
}
385+
}
390386
PyCodeObject *bytecode = (PyCodeObject *)PyFunction_GetCode(f); // borrowed reference
391387
PyObject *defaults = PyFunction_GetDefaults(f); // borrowed reference
392388
nDefaultArgs = defaults ? PyTuple_Size(defaults) : 0;
393-
if (bytecode->co_argcount == 0 && isMethod) {
394-
nNormalArgs += nDefaultArgs;
395-
} else {
396-
nNormalArgs += bytecode->co_argcount - nDefaultArgs - 1;
397-
}
389+
nNormalArgs += bytecode->co_argcount - nDefaultArgs - 1;
398390
if (bytecode->co_flags & CO_VARARGS) {
399391
varargs = true;
400392
}
401393
}
402394

403395
// use faster calling if no arguments are needed
404-
if (((nNormalArgs + nDefaultArgs) == 0 && !varargs)) {
396+
if (((nNormalArgs + nDefaultArgs) <= 0 && !varargs)) {
405397
#if PY_VERSION_HEX >= 0x03090000
406398
pyRval = PyObject_CallNoArgs(pyFunc);
407399
#else

0 commit comments

Comments
 (0)