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
This stays the same: fields = re.split('[ \t]+',line)
The payoff is when we get here:
iflen(fields) !=4:
# OK if 5th field exists and starts with #iflen(fields) <5ornotfields[4].startswith("#"):
self.log_entries.append("Incorrect format line: "+line)
continue
->
iflen(fields) ==4:
# Do what we're already doingeliflen(fields) ==6:
# https://github.com/TravelMapping/DataProcessing/issues/58else:
self.log_entries.append("Incorrect format line: "+line)
continue
OTOH, this would adversely affect performance. Worst case or even pretty close to average case (as most lines don't contain comments), we'd be scanning each line twice:
Iterate thru all fields or first 7, whichever's less
If we find a field starting with #, truncate the fields container to before that one, and break.
This makes sense from a Python perspective, the way the split function is already used to automate things.
In C++, we already have to populate the fields vector element-by-element, so it makes sense to not even add in fields beginning with #.
Slight speedup due to not having to process the whole line when splitting.
Or not. 0.07s slower on lab1, within margin of error. Inline comments are relatively rare, making the gains negligible. Also, there's a small amount more overhead now, checking whether each field starts with #.
Trying to mimic C++ style fields construction in Python is likely not worth the hassle, and may even be counter-productive performance-wise.
formulanone.log:
13c13< Waypoint label(s) not found in line: GA GA1LpRom # "GA746">GA20-AL9---> Incorrect format line: GA GA1LpRom # "GA746">GA20-AL9
Old version happens because 4 fields suggest a valid format .list line, and we attempt to parse both # and "GA746">GA20-AL9 as waypoint labels. New version happens because we truncate everything starting at the #, leaving only 2 fields, yielding an incorrect format line.
Addressed on BiggaTomato's local fork in 265c35d13a6a14e66da1d6cee134a3a31c038427.
This commit will most likely not make it to GitHub, as I plan to squash commits.
Activity
yakra commentedon Apr 17, 2020
OTOH, this would adversely affect performance. Worst case or even pretty close to average case (as most lines don't contain comments), we'd be scanning each line twice:
#to remove commentsA more complex solution may be in order.
yakra commentedon May 7, 2020
This is easy:
#, truncate thefieldscontainer to before that one, and break.I'll close this issue for housekeeping purposes, and let this be implemented as part of #58.
yakra commentedon May 13, 2020
This makes sense from a Python perspective, the way the
splitfunction is already used to automate things.fieldsvector element-by-element, so it makes sense to not even add in fields beginning with#.Slight speedup due to not having to process the whole line when splitting.Or not. 0.07s slower on lab1, within margin of error. Inline comments are relatively rare, making the gains negligible. Also, there's a small amount more overhead now, checking whether each field starts with
#.fieldsconstruction in Python is likely not worth the hassle, and may even be counter-productive performance-wise.yakra commentedon May 14, 2020
HighwayData @
27a625459516a8f5c53f73a24ce51416ab991677UserData @
3ec63996d33e499027a3d4c8f47abc0d3ce7659fOld version happens because 4 fields suggest a valid format .list line, and we attempt to parse both
#and"GA746">GA20-AL9as waypoint labels.New version happens because we truncate everything starting at the
#, leaving only 2 fields, yielding an incorrect format line.yakra commentedon May 14, 2020
Addressed on BiggaTomato's local fork in 265c35d13a6a14e66da1d6cee134a3a31c038427.
This commit will most likely not make it to GitHub, as I plan to squash commits.
.list processing enhancements