Skip to content

Commit

Permalink
Update sortedmapp to use meth_fastcall (#233)
Browse files Browse the repository at this point in the history
  • Loading branch information
frmdstryr authored Jan 20, 2025
1 parent 9b80362 commit 92a96a0
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions atom/src/sortedmap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -401,13 +401,12 @@ SortedMap_contains( SortedMap* self, PyObject* key )


PyObject*
SortedMap_get( SortedMap* self, PyObject* args )
SortedMap_get( SortedMap* self, PyObject*const *args, Py_ssize_t nargs )
{
Py_ssize_t nargs = PyTuple_GET_SIZE( args );
if( nargs == 1 )
return self->getitem( PyTuple_GET_ITEM( args, 0 ), Py_None );
return self->getitem( args[0], Py_None );
if( nargs == 2 )
return self->getitem( PyTuple_GET_ITEM( args, 0 ), PyTuple_GET_ITEM( args, 1 ) );
return self->getitem( args[0], args[1] );
std::ostringstream ostr;
if( nargs > 2 )
ostr << "get() expected at most 2 arguments, got " << nargs;
Expand All @@ -418,13 +417,12 @@ SortedMap_get( SortedMap* self, PyObject* args )


PyObject*
SortedMap_pop( SortedMap* self, PyObject* args )
SortedMap_pop( SortedMap* self, PyObject*const *args, Py_ssize_t nargs )
{
Py_ssize_t nargs = PyTuple_GET_SIZE( args );
if( nargs == 1 )
return self->pop( PyTuple_GET_ITEM( args, 0 ) );
return self->pop( args[0] );
if( nargs == 2 )
return self->getitem( PyTuple_GET_ITEM( args, 0 ), PyTuple_GET_ITEM( args, 1 ) );
return self->getitem( args[0], args[1] );
std::ostringstream ostr;
if( nargs > 2 )
ostr << "pop() expected at most 2 arguments, got " << nargs;
Expand Down Expand Up @@ -541,9 +539,9 @@ SortedMap_sizeof( SortedMap* self, PyObject* args )

static PyMethodDef
SortedMap_methods[] = {
{ "get", ( PyCFunction )SortedMap_get, METH_VARARGS,
{ "get", ( PyCFunction )SortedMap_get, METH_FASTCALL,
"" },
{ "pop", ( PyCFunction )SortedMap_pop, METH_VARARGS,
{ "pop", ( PyCFunction )SortedMap_pop, METH_FASTCALL,
"" },
{ "clear", ( PyCFunction)SortedMap_clearmethod, METH_NOARGS,
"" },
Expand Down

0 comments on commit 92a96a0

Please sign in to comment.