MCPcopy Create free account
hub / github.com/KentBeck/BPlusTree3 / fast_compare_eq

Function fast_compare_eq

python/bplustree_c_src/node_ops.c:43–65  ·  view source on GitHub ↗

Fast equality comparison function */

Source from the content-addressed store, hash-verified

41
42/* Fast equality comparison function */
43int 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 */
68int node_find_position(BPlusNode *node, PyObject *key) {

Callers 5

tree_find_leafFunction · 0.85
tree_insert_recursiveFunction · 0.85
node_insert_leafFunction · 0.85
node_deleteFunction · 0.85
node_getFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected