diff --git a/include/libcamera/base/log.h b/include/libcamera/base/log.h
index acef24203..1fb92603f 100644
--- a/include/libcamera/base/log.h
+++ b/include/libcamera/base/log.h
@@ -64,7 +64,7 @@ class LogMessage
 public:
 	LogMessage(const char *fileName, unsigned int line,
 		   const LogCategory &category, LogSeverity severity,
-		   const std::string &prefix = std::string());
+		   std::string prefix = {});
 	~LogMessage();
 
 	std::ostream &stream() { return msgStream_; }
diff --git a/src/libcamera/base/log.cpp b/src/libcamera/base/log.cpp
index c0e0be60f..6687deb93 100644
--- a/src/libcamera/base/log.cpp
+++ b/src/libcamera/base/log.cpp
@@ -858,11 +858,11 @@ const LogCategory &LogCategory::defaultCategory()
  */
 LogMessage::LogMessage(const char *fileName, unsigned int line,
 		       const LogCategory &category, LogSeverity severity,
-		       const std::string &prefix)
+		       std::string prefix)
 	: category_(category), severity_(severity),
 	  timestamp_(utils::clock::now()),
 	  fileInfo_((std::ostringstream() << utils::basename(fileName) << ":" << line).str()),
-	  prefix_(prefix)
+	  prefix_(std::move(prefix))
 {
 }
 
