Thrift string copy construction pathces from kevin ko
authorMark Slee <mcslee@apache.org>
Wed, 4 Apr 2007 21:08:21 +0000 (21:08 +0000)
committerMark Slee <mcslee@apache.org>
Wed, 4 Apr 2007 21:08:21 +0000 (21:08 +0000)
Summary: Remove unnecessary string copy constructions in C++ code

Reviewed By: mcslee

Test Plan: build

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665084 13f79535-47bb-0310-9956-ffa450edef68

lib/cpp/src/Thrift.h
lib/cpp/src/protocol/TBinaryProtocol.cpp
lib/cpp/src/protocol/TBinaryProtocol.h
lib/cpp/src/protocol/TProtocol.h
lib/cpp/src/protocol/TProtocolException.h
lib/cpp/src/transport/TTransportException.h

index 49668be..d024ad5 100644 (file)
@@ -28,7 +28,7 @@ class TException : public std::exception {
 public:
   TException() {}
 
-  TException(const std::string message) :
+  TException(const std::string& message) :
     message_(message) {}
 
   virtual ~TException() throw() {}
@@ -69,12 +69,12 @@ public:
     TException(), 
     type_(type) {}
 
-  TApplicationException(const std::string message) :
+  TApplicationException(const std::string& message) :
     TException(message),
     type_(UNKNOWN) {}
 
   TApplicationException(TApplicationExceptionType type,
-                        const std::string message) :
+                        const std::string& message) :
     TException(message),
     type_(type) {}
 
index 958572d..544ef88 100644 (file)
@@ -10,9 +10,9 @@ using std::string;
 
 namespace facebook { namespace thrift { namespace protocol { 
 
-uint32_t TBinaryProtocol::writeMessageBegin(const std::string name,
-                                           const TMessageType messageType,
-                                           const int32_t seqid) {
+uint32_t TBinaryProtocol::writeMessageBegin(const std::string& name,
+                                            const TMessageType messageType,
+                                            const int32_t seqid) {
   return 
     writeString(name) + 
     writeByte((int8_t)messageType) +
index 6a85491..89220e2 100644 (file)
@@ -56,9 +56,9 @@ class TBinaryProtocol : public TProtocol {
    * Writing functions.
    */
 
-  virtual uint32_t writeMessageBegin(const std::string name,
-                                    const TMessageType messageType,
-                                    const int32_t seqid);
+  virtual uint32_t writeMessageBegin(const std::string& name,
+                                     const TMessageType messageType,
+                                     const int32_t seqid);
 
   virtual uint32_t writeMessageEnd();
 
index 735268e..6264bb6 100644 (file)
@@ -88,9 +88,9 @@ class TProtocol {
    * Writing functions.
    */
 
-  virtual uint32_t writeMessageBegin(const std::string name,
-                                    const TMessageType messageType,
-                                    const int32_t seqid) = 0;
+  virtual uint32_t writeMessageBegin(const std::string& name,
+                                     const TMessageType messageType,
+                                     const int32_t seqid) = 0;
 
   virtual uint32_t writeMessageEnd() = 0;
 
index ba2fbfb..8f939c6 100644 (file)
@@ -42,11 +42,11 @@ class TProtocolException : public facebook::thrift::TException {
     facebook::thrift::TException(), 
     type_(type) {}
 
-  TProtocolException(const std::string message) :
+  TProtocolException(const std::string& message) :
     facebook::thrift::TException(message),
     type_(UNKNOWN) {}
 
-  TProtocolException(TProtocolExceptionType type, const std::string message) :
+  TProtocolException(TProtocolExceptionType type, const std::string& message) :
     facebook::thrift::TException(message),
     type_(type) {}
 
index 5083766..f865ecc 100644 (file)
@@ -43,11 +43,11 @@ class TTransportException : public facebook::thrift::TException {
     facebook::thrift::TException(), 
     type_(type) {}
 
-  TTransportException(const std::string message) :
+  TTransportException(const std::string& message) :
     facebook::thrift::TException(message),
     type_(UNKNOWN) {}
 
-  TTransportException(TTransportExceptionType type, const std::string message) :
+  TTransportException(TTransportExceptionType type, const std::string& message) :
     facebook::thrift::TException(message),
     type_(type) {}