mirror of
https://github.com/gabime/spdlog.git
synced 2025-10-02 11:29:01 +08:00
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:
@@ -21,7 +21,7 @@ namespace sinks
|
||||
* the output with an ANSI escape sequence color code depending on the severity
|
||||
* of the message.
|
||||
*/
|
||||
class ansicolor_sink : public sink
|
||||
class ansicolor_sink SPDLOG_FINAL : public sink
|
||||
{
|
||||
public:
|
||||
ansicolor_sink(sink_ptr wrapped_sink);
|
||||
|
@@ -31,7 +31,7 @@ public:
|
||||
base_sink(const base_sink&) = delete;
|
||||
base_sink& operator=(const base_sink&) = delete;
|
||||
|
||||
void log(const details::log_msg& msg) override
|
||||
void log(const details::log_msg& msg) SPDLOG_FINAL override
|
||||
{
|
||||
std::lock_guard<Mutex> lock(_mutex);
|
||||
_sink_it(msg);
|
||||
|
@@ -26,7 +26,7 @@ namespace sinks
|
||||
* Trivial file sink with single file as target
|
||||
*/
|
||||
template<class Mutex>
|
||||
class simple_file_sink : public base_sink < Mutex >
|
||||
class simple_file_sink SPDLOG_FINAL : public base_sink < Mutex >
|
||||
{
|
||||
public:
|
||||
explicit simple_file_sink(const filename_t &filename, bool truncate = false):_force_flush(false)
|
||||
@@ -61,7 +61,7 @@ typedef simple_file_sink<details::null_mutex> simple_file_sink_st;
|
||||
* Rotating file sink based on size
|
||||
*/
|
||||
template<class Mutex>
|
||||
class rotating_file_sink : public base_sink < Mutex >
|
||||
class rotating_file_sink SPDLOG_FINAL : public base_sink < Mutex >
|
||||
{
|
||||
public:
|
||||
rotating_file_sink(const filename_t &base_filename,
|
||||
@@ -177,7 +177,7 @@ struct dateonly_daily_file_name_calculator
|
||||
* Rotating file sink based on date. rotates at midnight
|
||||
*/
|
||||
template<class Mutex, class FileNameCalc = default_daily_file_name_calculator>
|
||||
class daily_file_sink :public base_sink < Mutex >
|
||||
class daily_file_sink SPDLOG_FINAL :public base_sink < Mutex >
|
||||
{
|
||||
public:
|
||||
//create daily file sink which rotates on given time
|
||||
|
@@ -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:
|
||||
|
Reference in New Issue
Block a user