mirror of
https://git.libcamera.org/libcamera/libcamera.git
synced 2025-07-12 14:59:44 +03:00
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:
parent
16bcc5a3e4
commit
24c2caa1c1
2 changed files with 16 additions and 14 deletions
|
@ -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_;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue