MCPcopy Create free account
hub / github.com/comaps/comaps / Diff

Method Diff

libs/indexer/feature_charge_sockets.cpp:401–428  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

399}
400
401KeyValueDiffSet ChargeSocketsHelper::Diff(ChargeSocketDescriptors const & oldSockets)
402{
403 KeyValueDiffSet result;
404
405 auto oldKeys = ChargeSocketsHelper(oldSockets).GetOSMKeyValues();
406 auto newKeys = GetOSMKeyValues();
407
408 ankerl::unordered_dense::map<std::string, std::string> oldMap, newMap;
409
410 for (auto && [k, v] : oldKeys)
411 oldMap.emplace(k, v);
412 for (auto && [k, v] : newKeys)
413 newMap.emplace(k, v);
414
415 // Handle keys that exist in old
416 for (auto && [k, oldVal] : oldMap)
417 if (auto it = newMap.find(k); it == newMap.end())
418 result.insert({k, oldVal, ""}); // deleted
419 else if (it->second != oldVal)
420 result.insert({k, oldVal, it->second}); // updated
421
422 // Handle keys that are only new
423 for (auto && [k, newVal] : newMap)
424 if (!oldMap.contains(k))
425 result.insert({k, "", newVal}); // created
426
427 return result;
428}
429
430void ChargeSocketsHelper::Sort()
431{

Callers 2

LogDiffInJournalMethod · 0.45
UNIT_TESTFunction · 0.45

Calls 6

ChargeSocketsHelperClass · 0.85
GetOSMKeyValuesMethod · 0.80
emplaceMethod · 0.45
findMethod · 0.45
endMethod · 0.45
insertMethod · 0.45

Tested by 1

UNIT_TESTFunction · 0.36