Skip to content

Commit b3b49ec

Browse files
committed
Minor tweak to how sorted keys are updated
1 parent f6e807f commit b3b49ec

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

orderbook/sorteddict.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,13 @@ inline int update_keys(SortedDict *self) {
213213
}
214214
}
215215

216+
/*
217+
It does seem like this code isnt necessarily needed.
218+
the PyDict_Keys function above returns a PyListObject which
219+
should suffice. It isnt strictly necessary to convert it to a tuple.
220+
After more extensive testing, this will be cleaned up
221+
should it prove to really be unnecessary.
222+
216223
PyObject *ret = PySequence_Tuple(keys);
217224
Py_DECREF(keys);
218225
if (EXPECT(!ret, 0)) {
@@ -221,9 +228,9 @@ inline int update_keys(SortedDict *self) {
221228
222229
if (self->keys) {
223230
Py_DECREF(self->keys);
224-
}
225-
226-
self->keys = ret;
231+
}*/
232+
Py_CLEAR(self->keys);
233+
self->keys = keys;
227234
self->dirty = false;
228235

229236
return 0;

0 commit comments

Comments
 (0)