| 1439 | } |
| 1440 | |
| 1441 | absl::StatusOr<bool> MessageFieldEquals( |
| 1442 | const Message& lhs, const FieldDescriptor* absl_nonnull lhs_field, |
| 1443 | const Message& rhs, const FieldDescriptor* absl_nonnull rhs_field, |
| 1444 | const DescriptorPool* absl_nonnull pool, |
| 1445 | MessageFactory* absl_nonnull factory) { |
| 1446 | ABSL_DCHECK(lhs_field != nullptr); |
| 1447 | ABSL_DCHECK(rhs_field != nullptr); |
| 1448 | ABSL_DCHECK(pool != nullptr); |
| 1449 | ABSL_DCHECK(factory != nullptr); |
| 1450 | if (&lhs == &rhs && lhs_field == rhs_field) { |
| 1451 | return true; |
| 1452 | } |
| 1453 | // MessageEqualsState has quite a large size, so we allocate it on the heap. |
| 1454 | // Ideally we should just hold most of the state at runtime in something like |
| 1455 | // `FlatExpressionEvaluatorState`, so we can avoid allocating this repeatedly. |
| 1456 | return std::make_unique<MessageEqualsState>(pool, factory) |
| 1457 | ->FieldEquals(lhs, lhs_field, rhs, rhs_field); |
| 1458 | } |
| 1459 | |
| 1460 | absl::StatusOr<bool> MessageFieldEquals( |
| 1461 | const google::protobuf::Message& lhs, const google::protobuf::Message& rhs, |