Thrift string copy construction pathces from kevin ko
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
diff --git a/lib/cpp/src/Thrift.h b/lib/cpp/src/Thrift.h
index 49668be..d024ad5 100644
--- a/lib/cpp/src/Thrift.h
+++ b/lib/cpp/src/Thrift.h
@@ -28,7 +28,7 @@
public:
TException() {}
- TException(const std::string message) :
+ TException(const std::string& message) :
message_(message) {}
virtual ~TException() throw() {}
@@ -69,12 +69,12 @@
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) {}
diff --git a/lib/cpp/src/protocol/TBinaryProtocol.cpp b/lib/cpp/src/protocol/TBinaryProtocol.cpp
index 958572d..544ef88 100644
--- a/lib/cpp/src/protocol/TBinaryProtocol.cpp
+++ b/lib/cpp/src/protocol/TBinaryProtocol.cpp
@@ -10,9 +10,9 @@
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) +
diff --git a/lib/cpp/src/protocol/TBinaryProtocol.h b/lib/cpp/src/protocol/TBinaryProtocol.h
index 6a85491..89220e2 100644
--- a/lib/cpp/src/protocol/TBinaryProtocol.h
+++ b/lib/cpp/src/protocol/TBinaryProtocol.h
@@ -56,9 +56,9 @@
* 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();
diff --git a/lib/cpp/src/protocol/TProtocol.h b/lib/cpp/src/protocol/TProtocol.h
index 735268e..6264bb6 100644
--- a/lib/cpp/src/protocol/TProtocol.h
+++ b/lib/cpp/src/protocol/TProtocol.h
@@ -88,9 +88,9 @@
* 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;
diff --git a/lib/cpp/src/protocol/TProtocolException.h b/lib/cpp/src/protocol/TProtocolException.h
index ba2fbfb..8f939c6 100644
--- a/lib/cpp/src/protocol/TProtocolException.h
+++ b/lib/cpp/src/protocol/TProtocolException.h
@@ -42,11 +42,11 @@
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) {}
diff --git a/lib/cpp/src/transport/TTransportException.h b/lib/cpp/src/transport/TTransportException.h
index 5083766..f865ecc 100644
--- a/lib/cpp/src/transport/TTransportException.h
+++ b/lib/cpp/src/transport/TTransportException.h
@@ -43,11 +43,11 @@
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) {}