diff options
author | Richard van der Hoff <richard@matrix.org> | 2018-04-03 17:33:02 +0100 |
---|---|---|
committer | Richard van der Hoff <richard@matrix.org> | 2018-04-03 17:33:02 +0100 |
commit | 17c8dedb66001dc89cb219b1dc1194d0a815b9d3 (patch) | |
tree | 471211db509173c6137fd05f6e4da9d711e2b3b8 /simplejson | |
parent | 0406430cbcb0e31d27bd064db57837b94ed05294 (diff) | |
download | simplejson-17c8dedb66001dc89cb219b1dc1194d0a815b9d3.tar.gz |
Defer is_raw_json test
Instances of RawJSON are unusual; by moving the test for them to lower in
encoder_listencode_obj, we get a 12% performance improvement in my tests by not
doing the instanceof test.
Diffstat (limited to 'simplejson')
-rw-r--r-- | simplejson/_speedups.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/simplejson/_speedups.c b/simplejson/_speedups.c index f352443..df23d15 100644 --- a/simplejson/_speedups.c +++ b/simplejson/_speedups.c @@ -2860,12 +2860,6 @@ encoder_listencode_obj(PyEncoderObject *s, JSON_Accu *rval, PyObject *obj, Py_ss if (encoded != NULL) rv = _steal_accumulate(rval, encoded); } - else if (is_raw_json(obj)) - { - PyObject *encoded = PyObject_GetAttrString(obj, "encoded_json"); - if (encoded != NULL) - rv = _steal_accumulate(rval, encoded); - } else if (PyInt_Check(obj) || PyLong_Check(obj)) { PyObject *encoded; if (PyInt_CheckExact(obj) || PyLong_CheckExact(obj)) { @@ -2933,6 +2927,12 @@ encoder_listencode_obj(PyEncoderObject *s, JSON_Accu *rval, PyObject *obj, Py_ss if (encoded != NULL) rv = _steal_accumulate(rval, encoded); } + else if (is_raw_json(obj)) + { + PyObject *encoded = PyObject_GetAttrString(obj, "encoded_json"); + if (encoded != NULL) + rv = _steal_accumulate(rval, encoded); + } else { PyObject *ident = NULL; PyObject *newobj; |