Skip to content

Commit

Permalink
minor optimize
Browse files Browse the repository at this point in the history
  • Loading branch information
kusharami committed Feb 3, 2021
1 parent c001e7f commit 6ad4695
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions BananaScript/ScriptUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ QScriptValue VariantToScriptValue(
switch (variant.type())
{
case QVariant::Map:
case QVariant::Hash:
{
auto vmap = variant.toMap();

Expand Down Expand Up @@ -204,14 +205,13 @@ QVariant ScriptValueToVariant(const QScriptValue &value, bool links)
} else if (value.isArray())
{
QVariantList vlist;

int len = value.property("length").toInt32();

for (int i = 0; i < len; i++)
int length = value.property(CSTRKEY(length)).toInt32();
vlist.reserve(length);
for (int i = 0; i < length; i++)
{
auto v = value.property(i);

vlist.push_back(ScriptValueToVariant(v, true));
vlist.append(ScriptValueToVariant(v, true));
}

return vlist;
Expand Down

0 comments on commit 6ad4695

Please sign in to comment.