You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The same DIFFs are visible in the logs.
I made the same syntactic changes in both languages. (I think.)
Got something wrong though.
Python diff:
3181d3180< selfref_found = False3186,3194c3185,3191< if w.label[w.label.index('/')+1:] == r.route[digit_starts+1:]:< selfref_found = True< if w.label[w.label.index('/')+1:] == r.route:< selfref_found = True< if '_' in w.label[w.label.index('/')+1:] and w.label[w.label.index('/')+1:w.label.rindex('_')] == r.route[digit_starts+1:]:< selfref_found = True< if '_' in w.label[w.label.index('/')+1:] and w.label[w.label.index('/')+1:w.label.rindex('_')] == r.route:< selfref_found = True<---> if w.label[w.label.index('/')+1:] == r.route[digit_starts+1:] \> or w.label[w.label.index('/')+1:] == r.route:> datacheckerrors.append(DatacheckEntry(r,[w.label],'LABEL_SELFREF'))> elif '_' in w.label[w.label.index('/')+1:]:> if w.label[w.label.index('/')+1:w.label.rindex('_')] == r.route[digit_starts+1:] \> or w.label[w.label.index('/')+1:w.label.rindex('_')] == r.route:> datacheckerrors.append(DatacheckEntry(r,[w.label],'LABEL_SELFREF'))3196c3193< if selfref_found or r.route+r.banner == w.label or re.fullmatch(r.route+r.banner+'[_/].*',w.label):---> elif r.route+r.banner == w.label or re.fullmatch(r.route+r.banner+'[_/].*',w.label):
I'll recheck my work. Edit: The last elif should be an if. Testing again.
// first check for number match after a slash, if there is oneconstchar* slash = strchr(l, '/');
if (slash)
{ constchar* digits = rte.data();
while (!isdigit(*digits) && *digits) ++digits;
if ( digits != rte.data()+rte.size()
&& !strdcmp(slash+1, digits, '_') && !coloc_same_number(digits)
|| !strdcmp(slash+1, rte.data(), '_') && !coloc_same_designation(rte)
) returnDatacheck::add(route, label, "", "", "LABEL_SELFREF", "");
}
// now the remaining checks
If strdcmp returns a match and coloc_same_number returns true, we go on to strdcmp(slash+1, rte.data(), '_') unnecessarily. We know it won't match because a label can't match the whole route name and just the digits at the same time. (Unless the route name is only digits. But then, still no need to compare, because coloc_same_designation will have the same result.)
The following variation avoids the unnecessary comparisons...
// first check for number match after a slash, if there is oneconstchar* slash = strchr(l, '/');
if (slash)
if (!strdcmp(slash+1, rte.data(), '_'))
{ if (!coloc_same_designation(rte))
returnDatacheck::add(route, label, "", "", "LABEL_SELFREF", "");
} else
{ constchar* digits = rte.data();
while (!isdigit(*digits) && *digits) ++digits;
if (digits != rte.data()+rte.size() && !strdcmp(slash+1, digits, '_') && !coloc_same_number(digits))
returnDatacheck::add(route, label, "", "", "LABEL_SELFREF", "");
}
// now the remaining checks
...and even skips finding where the digits are if it doesn't need them.
Just for good measure, another variation puts the digits comparison first again,
// first check for number match after a slash, if there is oneconstchar* slash = strchr(l, '/');
if (slash)
{ constchar* digits = rte.data();
while (!isdigit(*digits) && *digits) ++digits;
if (digits != rte.data()+rte.size() && !strdcmp(slash+1, digits, '_'))
{ if (!coloc_same_number(digits))
returnDatacheck::add(route, label, "", "", "LABEL_SELFREF", "");
} elseif (!strdcmp(slash+1, rte.data(), '_') && !coloc_same_designation(rte))
returnDatacheck::add(route, label, "", "", "LABEL_SELFREF", "");
}
// now the remaining checks
...just in case there are more digits matches, and the expense of always finding the digits is outweighed by avoiding more full route name matches.
The 2nd & 3rd versions take about 31.6% and 33% more time than the first version. Even though they avoid unnecessary string searches & comparisons. It must be outweighed by... a different branching structure? That's all that's different.
Maybe with the compound conditions, some items can be executed speculatively or in parallel, without having to wait for a separate branch statement. (Pipelining?) Interesting how this stuff gets optimized under the hood.
Activity
yakra commentedon Jan 17, 2019
Preceding
ifs can also be combined or becomeelifs.Compare whatever I end up doing in the C++ version.
yakra commentedon Jan 17, 2019
semi-related: check whether usanyp examples are flagged
yakra commentedon Jan 17, 2019
./siteupdate.py -e -l logs -c stats -u /home/yakra/TravelMapping/UserData/list_files -w /home/yakra/TravelMapping/HighwayData -t 1 | tee siteupdate_s1.logython/selfref.py -e -l logs -c stats -u /home/yakra/TravelMapping/UserData/list_files -w /home/yakra/TravelMapping/HighwayData -t 1 | tee siteupdate_s1.logBefore:
[355.2] Performing data checks...[383.2] Found 11190 datacheck errors.After:
[416.2] Performing data checks...[443.7] Found 11119 datacheck errors.There's work to do.
yakra commentedon Jan 17, 2019
datacheck.log
unmatchedfps.log
yakra commentedon Jan 18, 2019
The same DIFFs are visible in the logs.
I made the same syntactic changes in both languages. (I think.)
Got something wrong though.
Python diff:
I'll recheck my work.
Edit: The last
elifshould be anif. Testing again.[-]LABEL_SELFREF check[/-][+]LABEL_SELFREF efficiency[/+]yakra commentedon Nov 15, 2020
DataProcessing/siteupdate/cplusplus/classes/Waypoint/Waypoint.cpp
Lines 489 to 497 in e7eb26e
This can be boiled down...
(If pos is equal to the string length, [
std::string::operator[]] returns a reference to the null character that follows the last character in the string (which should not be modified).)yakra commentedon Nov 16, 2020
History:
r.route+r.banner == w.labelAlso note a commented-out "prehistoric" version, never part of production code, that had too many FPs to be useful.
_... or/...yakra commentedon Mar 2, 2021
The
high prioritytag on this issue doesn't mean high priority overall, but simply that this is higher priority than other LABEL_SELFREF issues.yakra commentedon Nov 15, 2021
Here's something a little weird:
If
strdcmpreturns a match andcoloc_same_numberreturns true, we go on tostrdcmp(slash+1, rte.data(), '_')unnecessarily. We know it won't match because a label can't match the whole route name and just the digits at the same time. (Unless the route name is only digits. But then, still no need to compare, becausecoloc_same_designationwill have the same result.)The following variation avoids the unnecessary comparisons...
...and even skips finding where the digits are if it doesn't need them.
Just for good measure, another variation puts the digits comparison first again,
...just in case there are more digits matches, and the expense of always finding the digits is outweighed by avoiding more full route name matches.
The 2nd & 3rd versions take about 31.6% and 33% more time than the first version. Even though they avoid unnecessary string searches & comparisons. It must be outweighed by... a different branching structure? That's all that's different.
Maybe with the compound conditions, some items can be executed speculatively or in parallel, without having to wait for a separate branch statement. (Pipelining?)
Interesting how this stuff gets optimized under the hood.