The push_front() method can cause reallocation of expanded_items,
thereby invalidating iterators already stored in m_recordItems.
Switching to std::list fixes this.
The translation between ParserRecord knows in advance how many DeckItem
entries there are in the resulting DeckRecord. We can use this
information to efficiently preallocate memory in the DeckRecord.
boost::trim_right loses a lot of performance from being locale aware.
Since this is not a problem for our ASCII fortran-type files, ignore
this issue and use isspace for trimming.
readValueToken spent almost half its time dealing with weirdly formed or
broken floats. Now has a shorter path that can early return a
successfully parsed float and only do slow handling of cases that need
it (notably zero, fortran style exponent and errors).
This function was rather slow and accounted for too much execution time.
Replaced with a simple implementation relying on toupper. Locale
awareness, the benefit of to_upper_copy, is not an issue since it's all
ASCII.
Instead of going via an immediately discarded temporary, feed the
readValueToken result value directly to push_back. This enables rvalue
optimisations to kick in, when available.
The boost provided lexical cast are inefficient and is shown to be a
slowdown in the inner loop. Replaces them with std::atoi/std::atof and
some simple correctness checking.
Modifies RawRecord to internally use string_view instead of copies of
the substrings. This *vastly* reduces copying in the processing of each
record and subsequently improves performance. Reduces total memory usage
in Deck construction.
A simple non-mutating view into a string. Implements a shallow reference
to a std::string, replicating its operations to be drop-in replaceable.
Primarily designed for inner loop use, where expensive string
allocations become a performance killer.
The templated readValueToken has been moved to source file, and uses
explicit instantiation and linking. The deprecated float specialisation
has been removed.