libcamera: base: log: Pass dynamic prefix through

Use move construction to essentially pass through the string
returned by `Loggable::logPrefix()` to avoid an unnecessary copy.

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 19:15:42 +01:00
parent 24c2caa1c1
commit aca8457d34
2 changed files with 3 additions and 3 deletions

View file

@ -64,7 +64,7 @@ class LogMessage
public: public:
LogMessage(const char *fileName, unsigned int line, LogMessage(const char *fileName, unsigned int line,
const LogCategory &category, LogSeverity severity, const LogCategory &category, LogSeverity severity,
const std::string &prefix = std::string()); std::string prefix = {});
~LogMessage(); ~LogMessage();
std::ostream &stream() { return msgStream_; } std::ostream &stream() { return msgStream_; }

View file

@ -858,11 +858,11 @@ const LogCategory &LogCategory::defaultCategory()
*/ */
LogMessage::LogMessage(const char *fileName, unsigned int line, LogMessage::LogMessage(const char *fileName, unsigned int line,
const LogCategory &category, LogSeverity severity, const LogCategory &category, LogSeverity severity,
const std::string &prefix) std::string prefix)
: category_(category), severity_(severity), : category_(category), severity_(severity),
timestamp_(utils::clock::now()), timestamp_(utils::clock::now()),
fileInfo_(static_cast<std::ostringstream &&>(std::ostringstream() << utils::basename(fileName) << ":" << line).str()), fileInfo_(static_cast<std::ostringstream &&>(std::ostringstream() << utils::basename(fileName) << ":" << line).str()),
prefix_(prefix) prefix_(std::move(prefix))
{ {
} }