-
Notifications
You must be signed in to change notification settings - Fork 126
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
replace random queues with QLists. #323
Conversation
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.
I'm still AFK, but skimming it, this is awesome. I think this is much more accessible to a developer and WAY less fragile. Thanx.
@@ -781,8 +791,7 @@ compare_strings(const QString& s1, const QString& s2) | |||
static writer_data_t* | |||
wdata_alloc() | |||
{ | |||
writer_data_t* res = (writer_data_t*) xcalloc(1, sizeof(*res)); | |||
QUEUE_INIT(&res->Q); | |||
auto res = new writer_data_t; | |||
waypt_init_bounds(&res->bds); |
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.
Some day, I think init_bounds() becomes part of the ctor for writer_data_t.
@@ -792,10 +801,7 @@ wdata_alloc() | |||
static void | |||
wdata_free(writer_data_t* data) |
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.
...and this becomes the dtor for writer_data about that same day. (I understand gravity and respect not getting sucked into it...)
if (data->ct > 1) { | ||
sortqueue(&data->Q, compare_wpt_cb); | ||
if (data->waypt_list.size() > 1) { | ||
std::stable_sort(data->waypt_list.begin(), data->waypt_list.end(), compare_wpt_cb); |
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.
We can use std:: on a QList. Huh. I wouldn't have thought to try that. That's cool!
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, and it is official: https://doc.qt.io/qt-5/containers.html#introduction
For traversing the items stored in a container, you can use one of two types of iterators: Java-style iterators and STL-style iterators. The Java-style iterators are easier to use and provide high-level functionality, whereas the STL-style iterators are slightly more efficient and can be used together with Qt's and STL's generic algorithms.
|
||
QUEUE_FOR_EACH(whichQueue, elem, tmp) { | ||
Waypoint* waypointp = reinterpret_cast<Waypoint*>(elem); | ||
foreach (Waypoint* waypointp, *whichQueue) { |
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.
This could turn into indexOf.
Or we could move mps and gdb into deprecate and never look at this code again. :-/
No description provided.