Elided the TYPE() and msgdef checks by using CLASS_OF.
diff --git a/ruby/ext/google/protobuf_c/message.c b/ruby/ext/google/protobuf_c/message.c
index e3e6f94..1eb0cb7 100644
--- a/ruby/ext/google/protobuf_c/message.c
+++ b/ruby/ext/google/protobuf_c/message.c
@@ -697,17 +697,13 @@
* 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) {