Skip to content
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

Merged
merged 1 commit into from
Mar 11, 2019

Conversation

tsteven4
Copy link
Collaborator

No description provided.

@tsteven4 tsteven4 merged commit c25b8ef into GPSBabel:master Mar 11, 2019
@tsteven4 tsteven4 deleted the more_queue_bye_bye branch March 11, 2019 23:50
Copy link
Collaborator

@GPSBabelDeveloper GPSBabelDeveloper left a 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);
Copy link
Collaborator

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)
Copy link
Collaborator

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);
Copy link
Collaborator

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!

Copy link
Collaborator Author

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) {
Copy link
Collaborator

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. :-/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants