Skip to content

Commit

Permalink
Elided the TYPE() and msgdef checks by using CLASS_OF.
Browse files Browse the repository at this point in the history
  • Loading branch information
haberman committed Apr 1, 2021
1 parent d69f482 commit 38e1b59
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions ruby/ext/google/protobuf_c/message.c
Original file line number Diff line number Diff line change
Expand Up @@ -697,17 +697,13 @@ bool Message_Equal(const upb_msg *m1, const upb_msg *m2, const upb_msgdef *m) {
* field is of a primitive type).
*/
static VALUE Message_eq(VALUE _self, VALUE _other) {
if (TYPE(_self) != TYPE(_other)) {
return Qfalse;
}
if (CLASS_OF(_self) != CLASS_OF(_other)) return Qfalse;

Message* self = ruby_to_Message(_self);
Message* other = ruby_to_Message(_other);
assert(self->msgdef == other->msgdef);

return self->msgdef == other->msgdef &&
Message_Equal(self->msg, other->msg, self->msgdef)
? Qtrue
: Qfalse;
return Message_Equal(self->msg, other->msg, self->msgdef) ? Qtrue : Qfalse;
}

uint64_t Message_Hash(const upb_msg* msg, const upb_msgdef* m, uint64_t seed) {
Expand Down

0 comments on commit 38e1b59

Please sign in to comment.