This is an automated email from the ASF dual-hosted git repository.

yiguolei pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/master by this push:
     new e0efda1234 [Improvement](Slice) support move constructor and operator 
for Slice (#23694)
e0efda1234 is described below

commit e0efda12348d1cb67d7eab1a3dfd5d8c76ba6520
Author: HHoflittlefish777 <77738092+hhoflittlefish...@users.noreply.github.com>
AuthorDate: Fri Sep 1 21:05:10 2023 +0800

    [Improvement](Slice) support move constructor and operator for Slice 
(#23694)
---
 be/src/util/slice.h | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/be/src/util/slice.h b/be/src/util/slice.h
index 84aec06c40..8997509a9f 100644
--- a/be/src/util/slice.h
+++ b/be/src/util/slice.h
@@ -80,6 +80,31 @@ public:
               data(const_cast<char*>(s)),
               size(strlen(s)) {}
 
+    Slice(const Slice& src) : data(src.data), size(src.size) {}
+
+    Slice& operator=(const Slice& src) {
+        if (this != &src) {
+            data = src.data;
+            size = src.size;
+        }
+        return *this;
+    }
+
+    Slice(Slice&& src) : data(src.data), size(src.size) {
+        src.data = nullptr;
+        src.size = 0;
+    }
+
+    Slice& operator=(Slice&& src) {
+        if (this != &src) {
+            data = src.data;
+            size = src.size;
+            src.data = nullptr;
+            src.size = 0;
+        }
+        return *this;
+    }
+
     /// @return A pointer to the beginning of the referenced data.
     const char* get_data() const { return data; }
 


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to