Both `if` branches have the same code
Solomon1732 opened this issue · comments
In the sub-function there is an if
statement in the cmp_items
internal function. That if
statement checks self.order.is_ask()
. However both the if
and the else
branch have the same code.
anydex-core/anydex/core/match_queue.py
Line 27 in 9d11982
Edit: since it seems like it would be a minor issue to solve, I don't mind adding the solution to #67
Good find, go ahead 👍
Ah, wait, I think I totally misread the code.
if self.order.is_ask():
if tup1[1] < tup2[1]:
return 1
else:
return -1
else:
if tup1[1] < tup2[1]:
return -1
else:
return 1
When looked at in isolation the returned value is -1 if the order is an ask
and 1 if not. Basically the results returned are flipped, depending on whether order
is an ask
or not. Uniting the two cases would break behavior.
My apologies for missing it and opening a frivolous issue. I totally missed the difference when reading it!
No problem! IIRC, the match queue was made quite close to the conference deadline, so I was a bit in a rush writing it. This did also not result in the most readable code 😁