Converting unordered_maps & unordered_sets to maps & sets (related: #216) can eliminate the need to sort existing containers.
Vectors can be sorted using std::sort.
Use lambdas where comparators aren't reused.
Functions:
functions=$(\
grep -h -m 1 'sort_[a-z_]*' `find . -name \*.cpp`\
| sed -e 's~.*\(sort_.*\)[()].*~\1~' -e 's~(.*~~'\
| sort | uniq)
echo -e "$functions\n"
for f in $functions; do
grep -n $f `find . -name \*.cpp`; echo
done
Regions
[x] ~Replace both Region::allregions and Region::code_hash with a std::map~
3725124 on BiggaTomato. Not going to worry about this. Made things slightly slower, absence of sorting notwithstanding.
Also yielded uglier code w/r.second everywhere. And that piecewise_construct is... verbose.
~No need to create & sort regions in allbyregionactivepreview~
~No need to create & sort regions in allbyregionactiveonly~
[ ] Replace HighwaySystem::mileage_by_region with a std::map
[ ] No need to create & sort regions in HighwaySystem::stats_csv
[ ] No need to create & sort sysregions in TravelerList::userlog
[ ] No need to create & sort regions_in_system for highwaydatastats.log in main
[ ] Replace TravelerList::active_preview_mileage_by_region with a std::map
[ ] No need to create & sort travregions in TravelerList::userlog
[ ] mark_connected_route_segments.cpp: make region_set a std::set
[ ] Performance? Where do we iterate through Region::allregions? It's a relatively small container though; impacts should be minimal. Maybe not noticeable at all.
Waypoints
[ ] Waypoint::near_miss_points can be a vector. Sort using std::sort. Will things be faster?
[ ] Will it be efficient to sort NMP lists in NmpSearchThread at this point?
[ ] WaypointQuadtree::points can be a vector. Sort using std::sort. Will things be faster?
Routes
[ ] Replace TravelerList::updated_routes with a std::set
[ ] Replace Route::sort_route_updates_oldest with a lambda
[ ] No need to create & sort route_list in TravelerList::userlog
[ ] This will move the sorting from TravelerList::userlog to TravelerList setup. How will this affect performance? FreeBSD in particular?
TravelerLists
[x] TMBitset was implemented for HighwaySegment::clinched_by in d9f0231 and the per-subgraph traveler_set in 634da8b. The TMBitsets always have their bits in the same order as (the pre-sorted) TravelerList::allusers. No sorting necessary.
Converting
unordered_map
s &unordered_set
s tomap
s &set
s (related: #216) can eliminate the need to sort existing containers. Vectors can be sorted using std::sort. Use lambdas where comparators aren't reused.Functions:
Region::allregions
andRegion::code_hash
with astd::map
~3725124
on BiggaTomato. Not going to worry about this. Made things slightly slower, absence of sorting notwithstanding. Also yielded uglier code w/r.second
everywhere. And thatpiecewise_construct
is... verbose.regions
inallbyregionactivepreview
~regions
inallbyregionactiveonly
~HighwaySystem::mileage_by_region
with astd::map
regions
inHighwaySystem::stats_csv
sysregions
inTravelerList::userlog
regions_in_system
for highwaydatastats.log inmain
TravelerList::active_preview_mileage_by_region
with astd::map
travregions
inTravelerList::userlog
region_set
astd::set
Waypoint::near_miss_points
can be a vector. Sort usingstd::sort
. Will things be faster?NmpSearchThread
at this point?WaypointQuadtree::points
can be a vector. Sort usingstd::sort
. Will things be faster?TravelerList::updated_routes
with astd::set
Route::sort_route_updates_oldest
with a lambdaroute_list
inTravelerList::userlog
TravelerList::userlog
toTravelerList
setup. How will this affect performance? FreeBSD in particular?TMBitset
was implemented forHighwaySegment::clinched_by
in d9f0231 and the per-subgraph traveler_set in 634da8b. The TMBitsets always have their bits in the same order as (the pre-sorted)TravelerList::allusers
. No sorting necessary.system_region_mileages?