mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Rework key prefix matching
Use C string comparison instead of C++ function std::mismatch to increase performance.
This commit is contained in:
parent
a13184978a
commit
322f2d99de
@ -242,11 +242,8 @@ void KvpFrame::for_each_slot_prefix(std::string const & prefix,
|
|||||||
std::for_each (m_valuemap.begin(), m_valuemap.end(),
|
std::for_each (m_valuemap.begin(), m_valuemap.end(),
|
||||||
[&prefix,&func](const KvpFrameImpl::map_type::value_type & a)
|
[&prefix,&func](const KvpFrameImpl::map_type::value_type & a)
|
||||||
{
|
{
|
||||||
std::string temp_key {a.first};
|
|
||||||
if (temp_key.size() < prefix.size())
|
|
||||||
return;
|
|
||||||
/* Testing for prefix matching */
|
/* Testing for prefix matching */
|
||||||
if (std::mismatch(prefix.begin(), prefix.end(), temp_key.begin()).first == prefix.end())
|
if (strncmp(a.first, prefix.c_str(), prefix.size()) == 0)
|
||||||
func (&a.first[prefix.size()], a.second);
|
func (&a.first[prefix.size()], a.second);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@ -259,11 +256,8 @@ void KvpFrame::for_each_slot_prefix(std::string const & prefix,
|
|||||||
std::for_each (m_valuemap.begin(), m_valuemap.end(),
|
std::for_each (m_valuemap.begin(), m_valuemap.end(),
|
||||||
[&prefix,&func,&data](const KvpFrameImpl::map_type::value_type & a)
|
[&prefix,&func,&data](const KvpFrameImpl::map_type::value_type & a)
|
||||||
{
|
{
|
||||||
std::string temp_key {a.first};
|
|
||||||
if (temp_key.size() < prefix.size())
|
|
||||||
return;
|
|
||||||
/* Testing for prefix matching */
|
/* Testing for prefix matching */
|
||||||
if (std::mismatch(prefix.begin(), prefix.end(), temp_key.begin()).first == prefix.end())
|
if (strncmp(a.first, prefix.c_str(), prefix.size()) == 0)
|
||||||
func (&a.first[prefix.size()], a.second, data);
|
func (&a.first[prefix.size()], a.second, data);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user