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

Function fast_compare_lt

python/bplustree_c_src/node_ops.c:17–40  ·  view source on GitHub ↗

Fast comparison function with type-specific optimizations */

Source from the content-addressed store, hash-verified

15
16/* Fast comparison function with type-specific optimizations */
17int fast_compare_lt(PyObject *a, PyObject *b) {
18 /* Fast path for integers */
19 if (PyLong_CheckExact(a) && PyLong_CheckExact(b)) {
20 /* For small integers, use direct comparison */
21 long val_a = PyLong_AsLong(a);
22 long val_b = PyLong_AsLong(b);
23 if (!PyErr_Occurred()) {
24 return val_a < val_b ? 1 : 0;
25 }
26 PyErr_Clear(); /* Clear error and fall through */
27 }
28
29 /* Fast path for strings */
30 if (PyUnicode_CheckExact(a) && PyUnicode_CheckExact(b)) {
31 int result = PyUnicode_Compare(a, b);
32 if (result != -1 || !PyErr_Occurred()) {
33 return result < 0 ? 1 : 0;
34 }
35 PyErr_Clear(); /* Clear error and fall through */
36 }
37
38 /* Fall back to general comparison */
39 return PyObject_RichCompareBool(a, b, Py_LT);
40}
41
42/* Fast equality comparison function */
43int fast_compare_eq(PyObject *a, PyObject *b) {

Callers 1

node_find_positionFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected