Explorar el Código

FileEntry: Pass by value for simple setter functions

Tatsuhiro Tsujikawa hace 12 años
padre
commit
a21a868af0
Se han modificado 2 ficheros con 9 adiciones y 9 borrados
  1. 6 6
      src/FileEntry.cc
  2. 3 3
      src/FileEntry.h

+ 6 - 6
src/FileEntry.cc

@@ -546,14 +546,14 @@ bool FileEntry::insertUri(const std::string& uri, size_t pos)
   return true;
 }
 
-void FileEntry::setPath(const std::string& path)
+void FileEntry::setPath(std::string path)
 {
-  path_ = path;
+  path_ = std::move(path);
 }
 
-void FileEntry::setContentType(const std::string& contentType)
+void FileEntry::setContentType(std::string contentType)
 {
-  contentType_ = contentType;
+  contentType_ = std::move(contentType);
 }
 
 size_t FileEntry::countInFlightRequest() const
@@ -566,9 +566,9 @@ size_t FileEntry::countPooledRequest() const
   return requestPool_.size();
 }
 
-void FileEntry::setOriginalName(const std::string& originalName)
+void FileEntry::setOriginalName(std::string originalName)
 {
-  originalName_ = originalName;
+  originalName_ = std::move(originalName);
 }
 
 bool FileEntry::emptyRequestUri() const

+ 3 - 3
src/FileEntry.h

@@ -109,7 +109,7 @@ public:
 
   const std::string& getPath() const { return path_; }
 
-  void setPath(const std::string& path);
+  void setPath(std::string path);
 
   int64_t getLength() const { return length_; }
 
@@ -167,7 +167,7 @@ public:
   // Inserts uris_ and spentUris_ into uris.
   void getUris(std::vector<std::string>& uris) const;
 
-  void setContentType(const std::string& contentType);
+  void setContentType(std::string contentType);
 
   const std::string& getContentType() const { return contentType_; }
 
@@ -257,7 +257,7 @@ public:
   // Push URIs in pooled or in-flight requests to the front of uris_.
   void putBackRequest();
 
-  void setOriginalName(const std::string& originalName);
+  void setOriginalName(std::string originalName);
 
   const std::string& getOriginalName() const
   {