Message ID | 20250121185044.300816-2-pobrn@protonmail.com |
---|---|
State | Superseded |
Headers | show |
Series |
|
Related | show |
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@protonmail.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@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)
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)
Move all fields of `LogMessage` in the move constructor. Signed-off-by: Barnabás Pőcze <pobrn@protonmail.com> --- src/libcamera/base/log.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)