Skip to content
Commit ef3235d9 authored by Friedrich W. H. Kossebau's avatar Friedrich W. H. Kossebau
Browse files

KEntryMap: for read access use heterogeneous lookup with view-like key type

Currently any look-up in KEntryMap requires a full instance of the key type.
Which in turn require a QString & QByteArray instance for group name &
key name respectively, as the members of KEntryKey type.
As the key name type supported in the public API currently can be either
QString or const char* (to UTF-8), this needs a deep copy into the
QByteArray instance used with KEntryKey instance used for the look-up.

std::map, as base class of KEntryMap, since C++14 supports heterogeneous
lookup, by the third template argument Compare. It enables to inject
further overloads of find(Key) with custom types.

So this introdudes a light-weight variant KEntryKeyView which uses
views instead of QString & QByteArray. The class is deployed for
any read-only look-up in the map.
KEntryMapTest is extended to test the comparisons between the normal
key type and the view type.
KEntryMap's & KConfigPrivate's read-access API are adapted to take in
the key type as view. This avoids the deep copy currently happening
for all the const char* arguments to a QByteArray instance in
the KConfigPrivate methods.

A new benchmark KConfigBenchmark is added. It for now tests the execution
time of KConfigGroup::hasKey() and KConfigGroup::readEntry().
It has been used to show a execution time reduction of ~ 15% by the
above given code changes.
parent 49104854
Pipeline #585202 passed with stage
in 4 minutes and 48 seconds
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment