fmtlegacy/include/fmt
Khalil Estell d11849bc0b
Add FMT_REDUCE_INT_INSTANTIATIONS flag (#1781)
* Remove <typename UInt> from int_writer

Reduce code bloat by removing multiple instantiation of int_writer based
on the <typename UInt> parameter.

Rationale:
- The only functions that gains a speedup by int size would be
  int_writer::on_dec()'s call to count_digits which uses CLZ. Thus to
  still take advantage of this speedup, we store the size of the int
  so we can use a switch statement to call the correct count_digits.
- All other implementations of count_digits require some sort of looping
  that terminates when the value hits zero regardless of what sized int
  it is.

Caveats:
- There is a performance hit when dealing with and passing around
  64-bit/128-bit values compared to 32-bit values on 32-bit platforms,
  and with 64-bit values on 64-bit systems. But this should not reduce the
  performance that dramatically.
- There is also a performance hit for on_dec() due to the addition of a
  switch case. But, due to it size, this should reduce to a jump table.

Resolves #1778

* Add FMT_USE_SMALLEST_INT flag

When defined and set to zero, will use the largest available integer
container for writing ints. The has the benefit of reducing instances
the of int_writer class which will reduce the binary cost.

* Rename flag to FMT_REDUCE_INT_INSTANTIATIONS

Add comment above FMT_REDUCE_INT_INSTANTIATIONS definition describing
why a developer would use it.

* Move FMT_REDUCE_INT_INSTANTIATIONS to format.h

Co-authored-by: Khalil Estell <kammce@google.com>
2020-07-19 13:09:10 -07:00
..
chrono.h Reuse format_decimal 2020-06-14 07:42:52 -07:00
color.h Move make_args_checked to the public API 2020-07-19 10:23:46 -07:00
compile.h Fix handling of code units in compile 2020-07-11 09:03:21 -07:00
core.h Move make_args_checked to the public API 2020-07-19 10:23:46 -07:00
format-inl.h Double buffering no more 2020-07-10 20:35:14 -07:00
format.h Add FMT_REDUCE_INT_INSTANTIATIONS flag (#1781) 2020-07-19 13:09:10 -07:00
locale.h Move make_args_checked to the public API 2020-07-19 10:23:46 -07:00
os.h Clarify a comment 2020-07-12 10:59:33 -07:00
ostream.h Move make_args_checked to the public API 2020-07-19 10:23:46 -07:00
posix.h Consistently namespace qualify size_t 2020-05-07 15:59:46 -07:00
printf.h Double buffering no more 2020-07-10 20:35:14 -07:00
ranges.h Adding sentinel support to fmt::join(). (#1689) 2020-05-18 06:31:01 -07:00