Details
-
Improvement
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
0.9.3, 0.10.0
-
None
Description
The identity check is cheap and should be done before comparing fields of a struct. Idiomatic equals methods always include this check especially if the field by field comparison can be expensive.
Check to add:
if(that == this) return true;
1864 out << indent() << "public boolean equals(" << tstruct->get_name() << " that) {" << endl;
1865 indent_up();
1866 out << indent() << "if (that == null)" << endl << indent() << " return false;" << endl;
INSERT IDENTITY CHECK HERE
1867
1868 const vector<t_field*>& members = tstruct->get_members();
1869 vector<t_field*>::const_iterator m_iter;
1870 for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
1871 out << endl;
1872
Attachments
Issue Links
- links to