MCPcopy Create free account
hub / github.com/cel-expr/cel-cpp / MapValueEqual

Function MapValueEqual

common/values/map_value.cc:225–268  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

223namespace common_internal {
224
225absl::Status MapValueEqual(
226 const MapValue& lhs, const MapValue& rhs,
227 const google::protobuf::DescriptorPool* absl_nonnull descriptor_pool,
228 google::protobuf::MessageFactory* absl_nonnull message_factory,
229 google::protobuf::Arena* absl_nonnull arena, Value* absl_nonnull result) {
230 ABSL_DCHECK(descriptor_pool != nullptr);
231 ABSL_DCHECK(message_factory != nullptr);
232 ABSL_DCHECK(arena != nullptr);
233 ABSL_DCHECK(result != nullptr);
234
235 CEL_ASSIGN_OR_RETURN(auto lhs_size, lhs.Size());
236 CEL_ASSIGN_OR_RETURN(auto rhs_size, rhs.Size());
237 if (lhs_size != rhs_size) {
238 *result = FalseValue();
239 return absl::OkStatus();
240 }
241 CEL_ASSIGN_OR_RETURN(auto lhs_iterator, lhs.NewIterator());
242 Value lhs_key;
243 Value lhs_value;
244 Value rhs_value;
245 for (size_t index = 0; index < lhs_size; ++index) {
246 ABSL_CHECK(lhs_iterator->HasNext()); // Crash OK
247 CEL_RETURN_IF_ERROR(
248 lhs_iterator->Next(descriptor_pool, message_factory, arena, &lhs_key));
249 bool rhs_value_found;
250 CEL_ASSIGN_OR_RETURN(
251 rhs_value_found,
252 rhs.Find(lhs_key, descriptor_pool, message_factory, arena, &rhs_value));
253 if (!rhs_value_found) {
254 *result = FalseValue();
255 return absl::OkStatus();
256 }
257 CEL_RETURN_IF_ERROR(
258 lhs.Get(lhs_key, descriptor_pool, message_factory, arena, &lhs_value));
259 CEL_RETURN_IF_ERROR(lhs_value.Equal(rhs_value, descriptor_pool,
260 message_factory, arena, result));
261 if (result->IsFalse()) {
262 return absl::OkStatus();
263 }
264 }
265 ABSL_DCHECK(!lhs_iterator->HasNext());
266 *result = TrueValue();
267 return absl::OkStatus();
268}
269
270absl::Status MapValueEqual(
271 const CustomMapValueInterface& lhs, const MapValue& rhs,

Callers 4

EqualMethod · 0.85
EqualMethod · 0.85
EqualMethod · 0.85
EqualMethod · 0.85

Calls 11

FalseValueFunction · 0.85
TrueValueFunction · 0.85
IsFalseMethod · 0.80
CustomMapValueClass · 0.70
CEL_ASSIGN_OR_RETURNFunction · 0.50
HasNextMethod · 0.45
NextMethod · 0.45
FindMethod · 0.45
GetMethod · 0.45
EqualMethod · 0.45
SizeMethod · 0.45

Tested by

no test coverage detected