diff options
| author | 2019-12-25 02:59:27 +0100 | |
|---|---|---|
| committer | 2019-12-25 02:59:27 +0100 | |
| commit | adf9031cf7ddf06d8806a2b8e4494984a21608b5 (patch) | |
| tree | 6b62b0043ff42ec53f8498dc670b65bae6ac5721 /cli | |
| parent | ad990b921d0d7dd67581369e98fa74209424edd9 (diff) | |
| download | OneRoll-adf9031cf7ddf06d8806a2b8e4494984a21608b5.tar.gz OneRoll-adf9031cf7ddf06d8806a2b8e4494984a21608b5.zip | |
Improve perf
Diffstat (limited to 'cli')
| -rw-r--r-- | cli/displaytoolbox.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/cli/displaytoolbox.cpp b/cli/displaytoolbox.cpp index fc2c7ed..9dc8fb6 100644 --- a/cli/displaytoolbox.cpp +++ b/cli/displaytoolbox.cpp @@ -121,6 +121,7 @@ QString DisplayToolBox::diceToSvg(QJsonArray array, bool withColor, bool allSame return result.join(""); } } +#include <QVariantList> QJsonArray DisplayToolBox::diceToJson(QList<ExportedDiceResult>& diceList, bool& allSameFaceCount, bool& allSameColor) { allSameFaceCount= true; @@ -137,8 +138,9 @@ QJsonArray DisplayToolBox::diceToJson(QList<ExportedDiceResult>& diceList, bool& { ListDiceResult diceResults= dice.value(face); QJsonObject object; - QJsonArray values; + QVariantList listVariant; object["face"]= static_cast<int>(face); + listVariant.reserve(diceResults.size()); for(auto const& dice : diceResults) { QJsonObject diceObj; @@ -158,9 +160,9 @@ QJsonArray DisplayToolBox::diceToJson(QList<ExportedDiceResult>& diceList, bool& } diceObj["subvalues"]= subValues; } - values.push_back(diceObj); + listVariant.append(QVariant::fromValue(diceObj)); } - object["values"]= values; + object["values"]= QJsonArray::fromVariantList(listVariant); array.push_back(object); } } |