yakra / DataProcessing

Data Processing Scripts and Programs for Travel Mapping Project
0 stars 0 forks source link

Waypoint::is_or_colocated_with_active_or_preview #277

Open yakra opened 4 months ago

yakra commented 4 months ago

https://github.com/yakra/DataProcessing/blob/387c99b0c260938c870457bb9793d4f78b09987f/siteupdate/cplusplus/classes/Waypoint/Waypoint.cpp#L172-L178

The following alternative has advantages for devel points...

bool Waypoint::is_or_colocated_with_active_or_preview()
{   if (!colocated) return route->system->active_or_preview();
    for (Waypoint *w : *colocated)
      if (w->route->system->active_or_preview()) return 1;
    return 0;
}

...and disadvantages for a/p points, of which there are more.

More to the point, its 2 use cases differ a bit in context, but both first check whether a point is singleton or at the front of its colocation list. Meaning, the colocated check here is redundant.

Edit: Potential new use case

Rather than remove the check & leave us with a function that could defy developer expectations & cause wacky antics if ever called on a singleton point, let's remove the function call overhead altogether. ;)