Skip to content

Optimize TupleObj

Gerhard Raven requested to merge optimize-tuple-memory-layout into master
  • remove one redundant layer of indirection in the storage of the 'value' -- items in a std::unordered_map are stable, so no need to store a unique_ptr<T>, and instead just store a T directly (as T is highly constraint already in order to be able to write it into an NTuple).
  • perform lookup by std::string_view instead of std::string as most usecases have a string literal (which is not an std::string) as argument, and previously, due to the use of std::string this implied at least copying the characters, and (in case of an overflow of the SBO of std::string) a memory allocation.
  • avoid creating an std::vector<std::string> in TupleObj::fill while tokenizing the format specifier.
  • avoid using C-style VA_ARGS in TupleObj::fill which assumes (without any checking) that all arguments (other than the format string) are double -- instead, use variadic template, and allow the arguments to be of different types.
Edited by Gerhard Raven

Merge request reports

Loading