Add an optional final qualifier to types

When building with GCC's -Wfinal-types, a lot of types of spdlog
are marked as being more optimizable if they were marked final.

This patch adds a possibility for the user of the library to `#define SPDLOG_FINAL final`
and enjoy potentially better performance : GCC is then able to replace virtual calls by true
function calls if it can ensure that there are no derived types).

By default SPDLOG_FINAL is defined to nothing to not break existing code that
may be inheriting of some of these types for some reason.
This commit is contained in:
Jean-Michaël Celerier
2017-04-28 17:24:55 +02:00
parent 9e6d81de08
commit 53138c20fb
8 changed files with 41 additions and 35 deletions

View File

@@ -18,7 +18,7 @@ namespace sinks
{
template <class Mutex>
class stdout_sink: public base_sink<Mutex>
class stdout_sink SPDLOG_FINAL : public base_sink<Mutex>
{
using MyType = stdout_sink<Mutex>;
public:
@@ -47,7 +47,7 @@ typedef stdout_sink<std::mutex> stdout_sink_mt;
template <class Mutex>
class stderr_sink: public base_sink<Mutex>
class stderr_sink SPDLOG_FINAL : public base_sink<Mutex>
{
using MyType = stderr_sink<Mutex>;
public: