Change in kio[master]: Add move semantics for UDSEntry. This also makes room for mo...

Mark Gaiser (Code Review) noreply at kde.org
Sun Jul 19 20:35:06 UTC 2015


Mark Gaiser has uploaded a new change for review.

  https://gerrit.vesnicky.cesnet.cz/r/474

Change subject: Add move semantics for UDSEntry. This also makes room for more performance improvements.
......................................................................

Add move semantics for UDSEntry. This also makes room for more performance improvements.

CHANGELOG: Add move semantics for UDSEntry.

Change-Id: I45dd8f799c38bb5bb0d0f3610f4a7b6c37994c67
---
M src/core/udsentry.cpp
M src/core/udsentry.h
2 files changed, 26 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.vesnicky.cesnet.cz:29418/kio refs/changes/74/474/1

diff --git a/src/core/udsentry.cpp b/src/core/udsentry.cpp
index 3efb45e..4263803 100644
--- a/src/core/udsentry.cpp
+++ b/src/core/udsentry.cpp
@@ -100,6 +100,11 @@
 {
 }
 
+UDSEntry::UDSEntry(UDSEntry &&other)
+    : d(std::move(other.d))
+{
+}
+
 UDSEntry::UDSEntry(const QT_STATBUF &buff, const QString &name)
     : d(new UDSEntryPrivate())
 {
@@ -127,6 +132,13 @@
     return *this;
 }
 
+UDSEntry &UDSEntry::operator=(UDSEntry &&other)
+{
+    d = std::move(other.d);
+    other.d = nullptr;
+    return *this;
+}
+
 QString UDSEntry::stringValue(uint field) const
 {
     auto result = std::find_if(d->fields.constBegin(), d->fields.constEnd(), [&field](const UDSEntryPrivate::Field &f){
diff --git a/src/core/udsentry.h b/src/core/udsentry.h
index 9b21530..d716b8e 100644
--- a/src/core/udsentry.h
+++ b/src/core/udsentry.h
@@ -65,6 +65,13 @@
     UDSEntry(const UDSEntry &other);
 
     /**
+     * Move constructor.
+     * @param other UDSEntry object.
+     * @since 5.13
+     */
+    UDSEntry(UDSEntry &&other);
+
+    /**
      * Create a UDSEntry by QT_STATBUF
      * @param buff QT_STATBUFF object
      * @param name filename
@@ -75,6 +82,13 @@
     UDSEntry &operator=(const UDSEntry &other);
 
     /**
+     * Move assignment operator.
+     * @param other UDSEntry object.
+     * @since 5.13
+     */
+    UDSEntry &operator=(UDSEntry &&other);
+
+    /**
      * @return value of a textual field
      */
     QString stringValue(uint field) const;

-- 
To view, visit https://gerrit.vesnicky.cesnet.cz/r/474
To unsubscribe, visit https://gerrit.vesnicky.cesnet.cz/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I45dd8f799c38bb5bb0d0f3610f4a7b6c37994c67
Gerrit-PatchSet: 1
Gerrit-Project: kio
Gerrit-Branch: master
Gerrit-Owner: Mark Gaiser <markg85 at gmail.com>


More information about the Kde-frameworks-devel mailing list