Commit 78e5a552 authored by Stefan Behnel's avatar Stefan Behnel

reverted PyDict_GetItem() implementation, replaced by selective optimisation in Py3

parent 1a6b77b5
...@@ -6494,30 +6494,24 @@ static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void) { ...@@ -6494,30 +6494,24 @@ static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void) {
getitem_dict_utility_code = UtilityCode( getitem_dict_utility_code = UtilityCode(
proto = """ proto = """
static PyObject *__Pyx_PyDict_GetItem(PyObject *o, PyObject* key) { static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key) {
long hash;
PyDictEntry *entry;
PyObject *value; PyObject *value;
if (unlikely(o == Py_None)) { if (unlikely(d == Py_None)) {
__Pyx_RaiseNoneIndexingError(); __Pyx_RaiseNoneIndexingError();
return NULL; return NULL;
} }
if (!PyString_CheckExact(key) || #if PY_MAJOR_VERSION >= 3
(hash = ((PyStringObject *) key)->ob_shash) == -1) { value = PyDict_GetItemWithError(d, key);
hash = PyObject_Hash(key); if (unlikely(!value)) {
if (hash == -1) return NULL; if (!PyErr_Occurred())
}
entry = ((PyDictObject*)o)->ma_lookup((PyDictObject*)o, key, hash);
if (likely(entry != NULL)) {
value = entry->me_value;
if (likely(value != NULL)) {
Py_INCREF(value);
return value;
} else {
PyErr_SetObject(PyExc_KeyError, key); PyErr_SetObject(PyExc_KeyError, key);
} return NULL;
} }
return NULL; Py_INCREF(value);
#else
value = PyObject_GetItem(d, key);
#endif
return value;
} }
""", """,
requires = [raise_noneindex_error_utility_code]) requires = [raise_noneindex_error_utility_code])
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment