Skip to content

Commit

Permalink
Remove dead code that used to handle the separate int type in Python 2
Browse files Browse the repository at this point in the history
  • Loading branch information
JustAnotherArchivist authored and bwoodsend committed Feb 20, 2022
1 parent fbae6a3 commit f9aa23b
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 59 deletions.
1 change: 0 additions & 1 deletion lib/ultrajson.h
Expand Up @@ -198,7 +198,6 @@ typedef struct __JSONObjectEncoder
const char *(*getStringValue)(JSOBJ obj, JSONTypeContext *tc, size_t *_outLen);
JSINT64 (*getLongValue)(JSOBJ obj, JSONTypeContext *tc);
JSUINT64 (*getUnsignedLongValue)(JSOBJ obj, JSONTypeContext *tc);
JSINT32 (*getIntValue)(JSOBJ obj, JSONTypeContext *tc);
double (*getDoubleValue)(JSOBJ obj, JSONTypeContext *tc);

/*
Expand Down
22 changes: 0 additions & 22 deletions lib/ultrajsonenc.c
Expand Up @@ -518,22 +518,6 @@ static void Buffer_AppendIndentUnchecked(JSONObjectEncoder *enc, JSINT32 value)
Buffer_AppendCharUnchecked(enc, ' ');
}

static void Buffer_AppendIntUnchecked(JSONObjectEncoder *enc, JSINT32 value)
{
char* wstr;
JSUINT32 uvalue = (value < 0) ? -value : value;

wstr = enc->offset;
// Conversion. Number is reversed.

do *wstr++ = (char)(48 + (uvalue % 10)); while(uvalue /= 10);
if (value < 0) *wstr++ = '-';

// Reverse string
strreverse(enc->offset,wstr - 1);
enc->offset += (wstr - (enc->offset));
}

static void Buffer_AppendLongUnchecked(JSONObjectEncoder *enc, JSINT64 value)
{
char* wstr;
Expand Down Expand Up @@ -771,12 +755,6 @@ static void encode(JSOBJ obj, JSONObjectEncoder *enc, const char *name, size_t c
break;
}

case JT_INT:
{
Buffer_AppendIntUnchecked (enc, enc->getIntValue(obj, &tc));
break;
}

case JT_TRUE:
{
Buffer_AppendCharUnchecked (enc, 't');
Expand Down
36 changes: 0 additions & 36 deletions python/objToJSON.c
Expand Up @@ -88,22 +88,6 @@ struct PyDictIterState
//#define PRINTMARK() fprintf(stderr, "%s: MARK(%d)\n", __FILE__, __LINE__)
#define PRINTMARK()

#ifdef _LP64
static void *PyIntToINT64(JSOBJ _obj, JSONTypeContext *tc, void *outValue, size_t *_outLen)
{
PyObject *obj = (PyObject *) _obj;
*((JSINT64 *) outValue) = PyLong_AsLong (obj);
return NULL;
}
#else
static void *PyIntToINT32(JSOBJ _obj, JSONTypeContext *tc, void *outValue, size_t *_outLen)
{
PyObject *obj = (PyObject *) _obj;
*((JSINT32 *) outValue) = PyLong_AsLong (obj);
return NULL;
}
#endif

static void *PyLongToINT64(JSOBJ _obj, JSONTypeContext *tc, void *outValue, size_t *_outLen)
{
*((JSINT64 *) outValue) = GET_TC(tc)->longValue;
Expand Down Expand Up @@ -521,17 +505,6 @@ static void Object_beginTypeContext (JSOBJ _obj, JSONTypeContext *tc, JSONObject
return;
}
else
if (PyLong_Check(obj))
{
PRINTMARK();
#ifdef _LP64
pc->PyTypeToJSON = PyIntToINT64; tc->type = JT_LONG;
#else
pc->PyTypeToJSON = PyIntToINT32; tc->type = JT_INT;
#endif
return;
}
else
if (UNLIKELY(PyBytes_Check(obj)))
{
PRINTMARK();
Expand Down Expand Up @@ -741,14 +714,6 @@ static JSUINT64 Object_getUnsignedLongValue(JSOBJ obj, JSONTypeContext *tc)
return ret;
}

static JSINT32 Object_getIntValue(JSOBJ obj, JSONTypeContext *tc)
{
JSINT32 ret;
obj = GET_OBJ(obj, tc);
GET_TC(tc)->PyTypeToJSON (obj, tc, &ret, NULL);
return ret;
}

static double Object_getDoubleValue(JSOBJ obj, JSONTypeContext *tc)
{
double ret;
Expand Down Expand Up @@ -810,7 +775,6 @@ PyObject* objToJSON(PyObject* self, PyObject *args, PyObject *kwargs)
Object_getStringValue,
Object_getLongValue,
Object_getUnsignedLongValue,
Object_getIntValue,
Object_getDoubleValue,
Object_iterNext,
Object_iterEnd,
Expand Down

0 comments on commit f9aa23b

Please sign in to comment.