Fast equality comparison function */
| 41 | |
| 42 | /* Fast equality comparison function */ |
| 43 | int fast_compare_eq(PyObject *a, PyObject *b) { |
| 44 | /* Fast path for integers */ |
| 45 | if (PyLong_CheckExact(a) && PyLong_CheckExact(b)) { |
| 46 | long val_a = PyLong_AsLong(a); |
| 47 | long val_b = PyLong_AsLong(b); |
| 48 | if (!PyErr_Occurred()) { |
| 49 | return val_a == val_b ? 1 : 0; |
| 50 | } |
| 51 | PyErr_Clear(); |
| 52 | } |
| 53 | |
| 54 | /* Fast path for strings */ |
| 55 | if (PyUnicode_CheckExact(a) && PyUnicode_CheckExact(b)) { |
| 56 | int result = PyUnicode_Compare(a, b); |
| 57 | if (result != -1 || !PyErr_Occurred()) { |
| 58 | return result == 0 ? 1 : 0; |
| 59 | } |
| 60 | PyErr_Clear(); |
| 61 | } |
| 62 | |
| 63 | /* Fall back to general comparison */ |
| 64 | return PyObject_RichCompareBool(a, b, Py_EQ); |
| 65 | } |
| 66 | |
| 67 | /* Binary search to find position for key */ |
| 68 | int node_find_position(BPlusNode *node, PyObject *key) { |
no outgoing calls
no test coverage detected