[](const auto *elem) { return static_cast<id_t>(elem->getId()); });
}
- auto containerLookupByKey(const List<NameScoresPair> *container, const char *key) const {
+ auto containerLookupByKey(const List<NameScoresPair> *container, boost::string_ref key) const {
return containerLookupByKey(container, key,
[](const auto *elem) { return elem->getName()->toStringRef(); });
}
};
auto searchAndUpdateCurrentBest = [¤tBest, &index, &updateCurrentBest, this](boost::string_ref name_ref) {
- // we need to create C-string for the lookups
- // boost::string_ref gives us correct start, but possibly NUL-terminated in a wrong place, as it does not modify
- // input string and keeps only the length
- std::string name(name_ref.data(), name_ref.size());
-
if (impl.containerEmpty(index))
return;
// check if there are any rules for the name
- auto fit = impl.containerLookupByKey(index, name.c_str());
+ auto fit = impl.containerLookupByKey(index, name_ref);
if (!fit.first)
return;