Using initializer_lists for QList we reserve the right amount of memory in advance and also make for nicer code.
Also uses range-for where code as touched and a const container was used.
Details
Test still pass.
asRealList is called 4200x on plasmashell startup for me, saves 2ms for me
Diff Detail
- Repository
- R237 KConfig
- Lint
Automatic diff as part of commit; lint not applicable. - Unit
Automatic diff as part of commit; unit tests not applicable.
it would probably be a good idea to rewrite KConfigGroupPrivate::serializeList to not take a QVariantList, but rather to use a streaming API. I.e. instead of:
void foo(myList) { varList = convertList(myList); write(KConfigGroupPrivate::serializeList(list)); }
Do something like:
void foo(myList) { var value = KConfigGroupPrivate::serializeList(mylist) write(value); }
where serializeList is a template that does $magic internally to convert a list of values to a serializeable format (i.e. iterate over values, then stream them into QDataStream/QTextStream, wrap in QVariant only when needed). Note that you can then use initializer_list for the "static" lists like for QPoint et al.
src/core/kconfiggroup.cpp | ||
---|---|---|
185 | can you make this (and the QList<qreal> below) a QVector instead? Would save 50% of memory on 64bit machines | |
187 | use splitRef instead, also below |
src/core/kconfiggroup.cpp | ||
---|---|---|
187 | Was my first reflex do to so but string confusingly is a QByteArray |
ah ok, and since we don't have a proper byte array view yet, there's nothing you can do (which is sad here!)
the other comments from me where suggestions for further improvements, they don't need to hold up this patch