[RFC PATCH v1 1/7] libcamera: base: log: Move all fields of `LogMessage`

Laurent Pinchart laurent.pinchart at ideasonboard.com
Fri Jan 24 17:22:35 CET 2025


Hi Barnabás,

Thank you for the patch.

On Tue, Jan 21, 2025 at 06:50:52PM +0000, Barnabás Pőcze wrote:
> Move all fields of `LogMessage` in the move constructor.
> 
> Signed-off-by: Barnabás Pőcze <pobrn at protonmail.com>

Reviewed-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>

but given that C++17 enforces copy elision, I think we could drop this
function completely (see the comment just above it).

> ---
>  src/libcamera/base/log.cpp | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/src/libcamera/base/log.cpp b/src/libcamera/base/log.cpp
> index 3a656b8f0..61a43d525 100644
> --- a/src/libcamera/base/log.cpp
> +++ b/src/libcamera/base/log.cpp
> @@ -17,6 +17,7 @@
>  #include <syslog.h>
>  #include <time.h>
>  #include <unordered_set>
> +#include <utility>
>  
>  #include <libcamera/logging.h>
>  
> @@ -894,9 +895,10 @@ LogMessage::LogMessage(const char *fileName, unsigned int line,
>   */
>  LogMessage::LogMessage(LogMessage &&other)
>  	: msgStream_(std::move(other.msgStream_)), category_(other.category_),
> -	  severity_(other.severity_)
> +	  severity_(std::exchange(other.severity_, LogInvalid)),
> +	  timestamp_(other.timestamp_), fileInfo_(std::move(other.fileInfo_)),
> +	  prefix_(std::move(other.prefix_))
>  {
> -	other.severity_ = LogInvalid;
>  }
>  
>  void LogMessage::init(const char *fileName, unsigned int line)

-- 
Regards,

Laurent Pinchart


More information about the libcamera-devel mailing list