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>
This commit is contained in:
Barnabás Pőcze 2025-01-21 18:47:49 +01:00
parent 16bcc5a3e4
commit 24c2caa1c1
2 changed files with 16 additions and 14 deletions

View file

@ -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_;