Skip to content

various minor improvements - #505

Closed
yakra wants to merge 7 commits into
TravelMapping:masterfrom
yakra:pyfloat_rebase
Closed

various minor improvements#505
yakra wants to merge 7 commits into
TravelMapping:masterfrom
yakra:pyfloat_rebase

Conversation

@yakra

@yakrayakra commented Mar 20, 2022

Copy link
Copy Markdown
Contributor

d2cdcaa set/map/dict cleanup

closesyakra#199

On the C++ side, this was mostly conceived as code-readability cleanup, but it ended up saving a little time on userlog generation, more noticeable on slower machines like lab3.

Python: In theory, saves a wee bit of time, not having to create new list objects from objects that are already iterable/searchable. In practice, it's down near the margin of error; the tiny improvements we can consistently see disappear under the larger fluctuations that happen naturally between runs in other parts of the program. Either way, the code's slightly cleaner.


c8b3c98 eliminates an unnecessary membership test

ifh.systemnameint.system_region_mileagesandregionint.system_region_mileages[h.systemname]:

if (system_region_mileages.count(h) && system_region_mileages.at(h).count(region))

The first half of the check is unnecessary because to get here...

t_system_overall=0.0
ifh.systemnameint.system_region_mileages:
t_system_overall=math.fsum(t.system_region_mileages[h.systemname].values())
ift_system_overall>0.0:

double t_system_overall = 0;
if (system_region_mileages.count(h))
t_system_overall = system_region_miles(h);
if (t_system_overall)

...t_system_overall has to be non-zero. But it's just been initialized to zero, and the only way for it to be set otherwise is if h.systemname in t.system_region_mileages.


597682e pyfloat

closesyakra#196

C++: minor speed improvements emulating "Python-style floats", where a single ".0" is appended to integer values.

  • Waypoint::str and Waypoint::nmplogs write to nearmisspoints.log & tm-master.nmp respectively.
  • Rather than apply similar changes to Route::csv_line and optionally adding "pyfloat" support to ConnectedRoute::csv_line to conform, these functions were removed in favor of inserting their elements directly into the file stream in sqlfile, for a small speedup. Python-style floats were dropped in the process; the odds of a Route or ConnectedRoute's mileage being an exact integer are close to zero. I'll cross that bridge if & when I come to it.
  • TravelerList::userlog is no-build for now, to avoid merge conflicts. I anticipate refactoring the relevant bits of code into the sqlfile1 function.

6e0693f fix potential buffer overflow & a3b35e0 comments

are what they say on the tin.


3ae68f1 don't store update in TravelerList

saves a tiny bit of RAM.


d56e5a6 update info retrieval

cleans up & consolidates the code that finds the update date & time for each .list file upon construction of its TravelerList object.

yakra added 7 commits March 6, 2022 10:31
remove unnecessary membership test
C++ from bc0f67a
Py from 2e80536
interactive rebase b54179c4e74277197b9d4efbcd47a01094f39179
This was introduced after the switch to clang, but only g++ reports it.
Doesn't need to be permanent.
cherrypick 1d29004ed4436f8b1d8db5b36f8e2587f3d37d48
@yakra

Copy link
Copy Markdown
ContributorAuthor

I thought this was ready for production, but at the last minute have come across some even better ways to approach some of the things that have been changed. Putting this on hold.

@yakrayakra closed this Mar 20, 2022
@yakra
yakra deleted the pyfloat_rebase branch March 22, 2022 16:46
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

unordered_set::count python style floats: strcat -> strcpy

1 participant

@yakra