-
Notifications
You must be signed in to change notification settings - Fork 502
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Review & Discuss] Update TxQueue to have a backing AVL Tree (Issues #189 #195) #198
Changes from 1 commit
906a5e4
01ad9c6
722f80b
f71bf9e
188eeb8
e743bf4
4223aea
3d16be6
ec17bb7
63b48c7
e0d9324
6f02ef3
36701bc
1a08155
bd69b04
2c12d20
41d92b6
6ebda4a
5b207da
d5a21fe
5df8572
e61e964
4986156
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- legacy-v0
- (#198)
- legacy-v0.5
- (#198)
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -81,11 +81,12 @@ class UAVCAN_EXPORT AvlTree : Noncopyable | |
return 0; | ||
} | ||
|
||
return static_cast<int16_t>(heightOf(n->left) - heightOf(n->right)); | ||
const int32_t diff = heightOf(n->left) - heightOf(n->right); | ||
return static_cast<int16_t>(std::max(-2, std::min(2, diff))); | ||
} | ||
|
||
static int16_t maxOf(int16_t a, int16_t b) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think we need to write this ourselves: https://en.cppreference.com/w/cpp/algorithm/max There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we care about semi-broken C++ implementations like that of NuttX (unless they fixed it since I last dealt with it), we must be extremely careful introducing new dependencies on STL. This is the reason why we have reinvented a huge wheel in I don't think that we should retain such drastic compatibility policies in bluesky, but this legacy code should remain compatible with older platforms. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okay. Shouldn't this go into templates.hpp then? I don't want to have multiple "min/max" functions lying around. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I guess it should. |
||
return static_cast<int16_t>(a > b ? a : b); | ||
return a > b ? a : b; | ||
} | ||
ntakouris marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
static Node* rotateRight(Node* y) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pavel wanted to use your maxOf but moved into templates.hpp. We'd also need minOf and an int32 version which suggests a template which then brings type traits to play if we want to prevent inefficient uses which will lead to another round of reviews and diving into the c++ spec...
fuck it.
Let's just go with minOf and maxOf here in this class.
I'm really sorry about the churn on this one line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given that this fails for
lpc11c24
,note: mismatched types 'std::initializer_list<_Tp>' and 'int' return static_cast<int16_t>(std::max(-2, std::min(2, diff)));
Do we keep the last version?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it should work when you switch back to your own versions of minOf/maxOf. Its failing because of changes to stl (see: @pavel-kirienko is almost always right)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but do I need to keep the
maxOf
&minOf
as-is, or move it to thetemplates.hpp
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can keep them here.