diff options
author | Barnabás Pőcze <pobrn@protonmail.com> | 2025-01-21 18:47:49 +0100 |
---|---|---|
committer | Barnabás Pőcze <pobrn@protonmail.com> | 2025-02-27 11:30:23 +0100 |
commit | 24c2caa1c1b39d0bb17dfaca0aedf9b8e91b5e26 (patch) | |
tree | a426f5f59c2670e03c8ee9b040226f07c17ef7f0 /include | |
parent | 16bcc5a3e47e445879fa515b795da8165e76fd99 (diff) |
libcamera: base: log: Use `std::string_view` to avoid some copies
Use `std::string_view` to avoid some largely unnecessary copies, and
to make string comparisong potentially faster by eliminating repeated
`strlen()` calls.
Signed-off-by: Barnabás Pőcze <pobrn@protonmail.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Diffstat (limited to 'include')
-rw-r--r-- | include/libcamera/base/log.h | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/include/libcamera/base/log.h b/include/libcamera/base/log.h index 4137d87a..acef2420 100644 --- a/include/libcamera/base/log.h +++ b/include/libcamera/base/log.h @@ -9,6 +9,7 @@ #include <atomic> #include <sstream> +#include <string_view> #include <libcamera/base/private.h> @@ -29,7 +30,7 @@ enum LogSeverity { class LogCategory { public: - static LogCategory *create(const char *name); + static LogCategory *create(std::string_view name); const std::string &name() const { return name_; } LogSeverity severity() const { return severity_.load(std::memory_order_relaxed); } @@ -38,7 +39,7 @@ public: static const LogCategory &defaultCategory(); private: - explicit LogCategory(const char *name); + explicit LogCategory(std::string_view name); const std::string name_; |