Skip to content

KConfigGroup: use QString as official group name data type

Currently there is a mismatch of the group name types used for input arguments, output arguments and internal storage

Output QString exclusively:

  • QString KConfigGroup::name() const
  • virtual QStringList KConfigBase::groupList() const
  • D-Bus signal of org.kde.kconfig.notify::ConfigChanged: QHash<QString, QByteArrayList>> (group name , key list)
  • all of KConfig*Skeleton* API

Input: some overloads with QString and QByteArray/const char*, others QString only:

  • QMap<QString, QString> KConfig::entryMap(const QString &aGroup) const
  • all of KConfig*Skeleton* API only QString

Internal storage:

  • QByteArray

Result: for many API calls this costs every time runtime encoding conversions including memalloc.

Abstract solution: standardizing on a type for all of input, output & storage.

Considerations:

  • output args as well as the skeleton classes made their pick already, QString
  • input arg all have QString overload
  • the number of config groups are << 1000, so optimizing on encoding size might be low priority even more when avoiding deep copies other than currently happening
  • some config group names are computed, QString used with arg() etc. utils, QByteArray only has number()
  • existing code happily often passes literals, resulting in deep copies to QByteArray
  • the use of QStringLiteral (next to QByteArrayLiteral & QLatin1String) for other string API is widely accepted
  • when used as input args to generate instancen, e.g. KConfigGroup constructors, the arg needs to outlive the calling scope i.e. views would always mean deep copies

Concrete solution:

  • standardizing on QString as documented official group name data type. Will work with existing API consumer codebase.
  • deprecating the QByteArray/const char* overloads (only in master, to be removed for KF 6.0) to fully gain with the reduction of runtime conversions
Edited by Friedrich W. H. Kossebau

Merge request reports