Prefer inline over static inline for free standing functions

When you mark free standing functions as `static inline` instead
of just `inline` they can not get merged across TUs and therefore
produce code bloat which is bad for the binaries size, the CPUs
instruction cache, and so on.

Please also see the discussion at:

- https://groups.google.com/forum/#!topic/mozilla.dev.platform/Ulw9HoZbSyQ
- http://stackoverflow.com/a/12836392

Note that non-fully specialized templates (i.e. with a kind of at
least `Template :: * -> *`) are `inline` by default.
This commit is contained in:
Daniel J. Hofmann 2016-01-08 23:33:31 +01:00
parent 6991a38703
commit 21804aecdb

View File

@ -15,7 +15,7 @@ namespace util
// precision: position after decimal point
// length: maximum number of digits including comma and decimals
// work with negative values to prevent overflowing when taking -value
template <int length, int precision> static inline char *printInt(char *buffer, int value)
template <int length, int precision> char *printInt(char *buffer, int value)
{
static_assert(length > 0, "length must be positive");
static_assert(precision > 0, "precision must be positive");