| 1836 | } |
| 1837 | |
| 1838 | bool StructEqual(const google::protobuf::MessageLite& lhs, |
| 1839 | const google::protobuf::MessageLite& rhs) { |
| 1840 | const int lhs_size = lhs_accessor_->FieldsSize(lhs); |
| 1841 | const int rhs_size = rhs_accessor_->FieldsSize(rhs); |
| 1842 | if (lhs_size != rhs_size) { |
| 1843 | return false; |
| 1844 | } |
| 1845 | if (lhs_size == 0) { |
| 1846 | return true; |
| 1847 | } |
| 1848 | std::string lhs_key_scratch; |
| 1849 | well_known_types::StringValue lhs_key; |
| 1850 | const google::protobuf::MessageLite* absl_nonnull lhs_value; |
| 1851 | auto lhs_iterator = lhs_accessor_->IterateFields(lhs); |
| 1852 | for (int i = 0; i < lhs_size; ++i) { |
| 1853 | std::tie(lhs_key, lhs_value) = lhs_iterator.Next(lhs_key_scratch); |
| 1854 | if (const auto* rhs_value = rhs_accessor_->FindField( |
| 1855 | rhs, absl::visit( |
| 1856 | absl::Overload( |
| 1857 | [](absl::string_view string) -> absl::string_view { |
| 1858 | return string; |
| 1859 | }, |
| 1860 | [&lhs_key_scratch]( |
| 1861 | const absl::Cord& cord) -> absl::string_view { |
| 1862 | if (auto flat = cord.TryFlat(); flat) { |
| 1863 | return *flat; |
| 1864 | } |
| 1865 | absl::CopyCordToString(cord, &lhs_key_scratch); |
| 1866 | return absl::string_view(lhs_key_scratch); |
| 1867 | }), |
| 1868 | AsVariant(lhs_key))); |
| 1869 | rhs_value == nullptr || !ValueEqual(*lhs_value, *rhs_value)) { |
| 1870 | return false; |
| 1871 | } |
| 1872 | } |
| 1873 | return true; |
| 1874 | } |
| 1875 | |
| 1876 | private: |
| 1877 | const JsonAccessor* absl_nonnull const lhs_accessor_; |
no test coverage detected