Repository navigation
Open
Labels
Description
induction variables
In siteupdate.py, the enumerate function was used in 2 places:
- create label hashes and check for duplicates
Changes, commited locally but not yet pushed, for HIDDEN_JUNCTION w/devel data, will modify this to use induction variables.Nope. Decided against that.
- canonical_waypoint_name for 3+_intersection cases
- Cleaning up
ap_coloc[check]andap_coloc[other]indexing can improve readability.
Or not. Tons of new code, makingap_colocindexing a much smaller piece of the pie. Keeping it in place can make the commit diffs more readable.
- Cleaning up
suffix efficiency
DataProcessing/siteupdate/cplusplus/classes/Waypoint/canonical_waypoint_name/3plus_intersection.cpp
Lines 28 to 34 in 03a36ca
| const char* suffix = strchr(ap_coloc[check]->label.data(), '_'); | |
| if (suffix | |
| // we confirmed above that other_no_abbrev matches, so skip past it | |
| // we need only match the suffix with or without the abbrev | |
| && (!strcmp(ap_coloc[check]->label.data()+other_no_abbrev.size(), suffix) | |
| || ap_coloc[check]->label.data()+other_no_abbrev.size() == ap_coloc[other]->route->abbrev + suffix | |
| )) suffixes[other] = suffix; |
Unnecessary comparison on top of unnecessary scanning. This whole thing's still a little Pythonic. :)
We do want to scan, because a suffix may come after a slashed designation. TravelMapping#418 (comment)
The bullet points below don't really apply anymore. Just look at the code in the next post.
- Just check for
_at the appropriate place:
if (check->label[other_no_abbrev.size()] == '_') suffixes[index] = check->label.data()+other_no_abbrev.size(); - The
||bit can become:
else if (!strncmp(check->label.data()+other_no_abbrev.size(), other->route->abbrev.data(), other->route->abbrev.size()) && check->label[other_no_abbrev.size()+other->route->abbrev.size()] == '_') suffixes[index] = check->label.data()+other_no_abbrev.size()+other->route->abbrev.size(); - This is all very wordy though. Improve readability by keeping/reintroducing the
const char* suffixvariable.- This time, initialize it to the position within the label.
- Dereference to check whether
_. - If the first part of the conditional before the
||doesn't produce results, just advance it:
suffix += other->route->abbrev.size(); - Keep the whole conditional as an
||instead of anelse if, and save on instruction cache & program size by using one singlesuffixes[index] = suffix;
comment
- I've had to figure this out at least twice, so add a comment here (or equivalent):
// It's tempting to break here as we have a match for this check. // But we need to keep going to ensure suffixes are populated.
Activity
yakra commentedon Mar 20, 2024
These cases should be taken care of now, so remove
// TODO: N493@RingSpi&RingSpi@N493_E&RingSpi@N493_W -> N493_W/RingSpi/RingSpiChange the description: no longer "starts with"; with/without abbrev is less of a "second check" now
Cutting out what I can (not much) & sliding left to fit onscreen
Route* &r = ap_coloc[other]->route;strncmpusing this compiles the same;keep the
other_no_abbrevassignment line unchanged in the diff.strncmp.