@@ -21,28 +21,6 @@ StructOrUnion::StructOrUnion(std::string name,
21
21
22
22
std::string StructOrUnion::getName () const { return name; }
23
23
24
- bool StructOrUnion::equals (const StructOrUnion &other) const {
25
- if (this == &other) {
26
- return true ;
27
- }
28
- if (isInstanceOf<const Struct>(&other)) {
29
- auto *s = dynamic_cast <const Struct *>(&other);
30
- if (name != s->name ) {
31
- return false ;
32
- }
33
- if (fields.size () != s->fields .size ()) {
34
- return false ;
35
- }
36
- for (size_t i = 0 ; i < fields.size (); i++) {
37
- if (*fields[i] != *s->fields [i]) {
38
- return false ;
39
- }
40
- }
41
- return true ;
42
- }
43
- return false ;
44
- }
45
-
46
24
std::shared_ptr<Location> StructOrUnion::getLocation () const {
47
25
return location;
48
26
}
@@ -142,17 +120,21 @@ bool Struct::usesType(const std::shared_ptr<Type> &type,
142
120
bool stopOnTypeDefs) const {
143
121
for (const auto &field : fields) {
144
122
if (*field->getType () == *type ||
145
- field->getType (). get () ->usesType (type, stopOnTypeDefs)) {
123
+ field->getType ()->usesType (type, stopOnTypeDefs)) {
146
124
return true ;
147
125
}
148
126
}
149
127
return false ;
150
128
}
151
129
152
130
bool Struct::operator ==(const Type &other) const {
131
+ if (this == &other) {
132
+ return true ;
133
+ }
153
134
auto *s = dynamic_cast <const Struct *>(&other);
154
135
if (s) {
155
- return this ->equals (*s);
136
+ /* structs have unique names */
137
+ return name == s->name ;
156
138
}
157
139
return false ;
158
140
}
@@ -290,9 +272,13 @@ std::string Union::generateHelperClass() const {
290
272
std::string Union::getTypeAlias () const { return " union_" + name; }
291
273
292
274
bool Union::operator ==(const Type &other) const {
275
+ if (this == &other) {
276
+ return true ;
277
+ }
293
278
auto *u = dynamic_cast <const Union *>(&other);
294
279
if (u) {
295
- return this ->equals (*u);
280
+ /* unions have unique names */
281
+ return name == u->name ;
296
282
}
297
283
return false ;
298
284
}
0 commit comments