Skip to content

Commit 92a96a0

Browse files
authored
Update sortedmapp to use meth_fastcall (#233)
1 parent 9b80362 commit 92a96a0

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

atom/src/sortedmap.cpp

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -401,13 +401,12 @@ SortedMap_contains( SortedMap* self, PyObject* key )
401401

402402

403403
PyObject*
404-
SortedMap_get( SortedMap* self, PyObject* args )
404+
SortedMap_get( SortedMap* self, PyObject*const *args, Py_ssize_t nargs )
405405
{
406-
Py_ssize_t nargs = PyTuple_GET_SIZE( args );
407406
if( nargs == 1 )
408-
return self->getitem( PyTuple_GET_ITEM( args, 0 ), Py_None );
407+
return self->getitem( args[0], Py_None );
409408
if( nargs == 2 )
410-
return self->getitem( PyTuple_GET_ITEM( args, 0 ), PyTuple_GET_ITEM( args, 1 ) );
409+
return self->getitem( args[0], args[1] );
411410
std::ostringstream ostr;
412411
if( nargs > 2 )
413412
ostr << "get() expected at most 2 arguments, got " << nargs;
@@ -418,13 +417,12 @@ SortedMap_get( SortedMap* self, PyObject* args )
418417

419418

420419
PyObject*
421-
SortedMap_pop( SortedMap* self, PyObject* args )
420+
SortedMap_pop( SortedMap* self, PyObject*const *args, Py_ssize_t nargs )
422421
{
423-
Py_ssize_t nargs = PyTuple_GET_SIZE( args );
424422
if( nargs == 1 )
425-
return self->pop( PyTuple_GET_ITEM( args, 0 ) );
423+
return self->pop( args[0] );
426424
if( nargs == 2 )
427-
return self->getitem( PyTuple_GET_ITEM( args, 0 ), PyTuple_GET_ITEM( args, 1 ) );
425+
return self->getitem( args[0], args[1] );
428426
std::ostringstream ostr;
429427
if( nargs > 2 )
430428
ostr << "pop() expected at most 2 arguments, got " << nargs;
@@ -541,9 +539,9 @@ SortedMap_sizeof( SortedMap* self, PyObject* args )
541539

542540
static PyMethodDef
543541
SortedMap_methods[] = {
544-
{ "get", ( PyCFunction )SortedMap_get, METH_VARARGS,
542+
{ "get", ( PyCFunction )SortedMap_get, METH_FASTCALL,
545543
"" },
546-
{ "pop", ( PyCFunction )SortedMap_pop, METH_VARARGS,
544+
{ "pop", ( PyCFunction )SortedMap_pop, METH_FASTCALL,
547545
"" },
548546
{ "clear", ( PyCFunction)SortedMap_clearmethod, METH_NOARGS,
549547
"" },

0 commit comments

Comments
 (0)