diff options
author | Bryan Duxbury <bryanduxbury@apache.org> | 2011-03-23 18:15:19 +0000 |
---|---|---|
committer | Bryan Duxbury <bryanduxbury@apache.org> | 2011-03-23 18:15:19 +0000 |
commit | 1709d40b4f33d034e63dcf7803202891834bba05 (patch) | |
tree | edd32c0c4ca454bdbde151cbcedeedf5f18db09b | |
parent | d081dd668b4c8d11de68d4e2047b3e54cfc21ec3 (diff) | |
download | thrift-1709d40b4f33d034e63dcf7803202891834bba05.tar.gz |
THRIFT-1107. py: improvement for compiler-generated python for 'None' object comparisons
This patch switches from 'x != None' to 'x is not None' for a small performance boost.
Patch: Will Pierce
git-svn-id: https://svn.apache.org/repos/asf/thrift/trunk@1084661 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | compiler/cpp/src/generate/t_py_generator.cc | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/compiler/cpp/src/generate/t_py_generator.cc b/compiler/cpp/src/generate/t_py_generator.cc index b6b0ab4e8..dbeed5d44 100644 --- a/compiler/cpp/src/generate/t_py_generator.cc +++ b/compiler/cpp/src/generate/t_py_generator.cc @@ -827,7 +827,7 @@ void t_py_generator::generate_py_struct_writer(ofstream& out, for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) { // Write field header indent(out) << - "if self." << (*f_iter)->get_name() << " != None:" << endl; + "if self." << (*f_iter)->get_name() << " is not None:" << endl; indent_up(); indent(out) << "oprot.writeFieldBegin(" << @@ -1064,7 +1064,7 @@ void t_py_generator::generate_service_client(t_service* tservice) { } else { f_service_ << indent() << " self._iprot = self._oprot = iprot" << endl << - indent() << " if oprot != None:" << endl << + indent() << " if oprot is not None:" << endl << indent() << " self._oprot = oprot" << endl << indent() << " self._seqid = 0" << endl << endl; @@ -1233,7 +1233,7 @@ void t_py_generator::generate_service_client(t_service* tservice) { // Careful, only return _result if not a void function if (!(*f_iter)->get_returntype()->is_void()) { f_service_ << - indent() << "if result.success != None:" << endl; + indent() << "if result.success is not None:" << endl; if (gen_twisted_) { f_service_ << indent() << " return d.callback(result.success)" << endl; @@ -1248,7 +1248,7 @@ void t_py_generator::generate_service_client(t_service* tservice) { vector<t_field*>::const_iterator x_iter; for (x_iter = xceptions.begin(); x_iter != xceptions.end(); ++x_iter) { f_service_ << - indent() << "if result." << (*x_iter)->get_name() << " != None:" << endl; + indent() << "if result." << (*x_iter)->get_name() << " is not None:" << endl; if (gen_twisted_) { f_service_ << indent() << " return d.errback(result." << (*x_iter)->get_name() << ")" << endl; |