Closed yakra closed 2 years ago
Dynamically (re)allocate as it goes.
This appears to be what happens in any case. Creating an 11-char string with all the constructors yields a 15-char capacity, every time, in both g++ and clang++. Capacity doubles whenever more is needed. Not much harm comes from this; almost all route names & labels are well below this threshold. Standard OSM URLs with 6 decimal places top out right at 60 B, and will only need to reallocate twice. Worse than nothing, but hey.
Performance appears to be marginally worse, right at margin of error.
Problem with constructing a
std::string
from a rawchar*
is the computer doesn't immediately know how much space to allocate. It must either...strlen
or equivalent, and scan through the whole string, orBoth of which waste time. If we know in advance how much space will be needed, let's use this to our advantage.
Waypoint
ctor, label & AltLabel constructionTravelerList
ctor:orig_line
&trim_line
HighwaySystem::route_integrity
?