-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Open
Description
using namespace simdjson;
int foreach_found_field(auto&& apply, ondemand::object& o, auto const&... ks)
{
auto mks = std::array{std::pair<bool, std::string_view>{false, ks}...};
int leftKs = mks.size();
for(ondemand::field fld : o)
{
int i = 0;
for(auto&[matched, k] : mks)
{
if(! matched && fld.key() == k)
{
apply(i, fld);
matched = true;
if(--leftKs == 0)
return 0;
break;
}
++i;
}
}
return leftKs;
}
For each field in object, it searches field key in target keys until all target keys are found or no more field. It scans the object at most once, which could avoid worst cases in existing find methods.
Metadata
Metadata
Assignees
Labels
No labels