From 6ad469541d93a6192e839cd066f942169800cee1 Mon Sep 17 00:00:00 2001 From: Alexandra Cherdantseva Date: Wed, 3 Feb 2021 16:04:25 +0300 Subject: [PATCH] minor optimize --- BananaScript/ScriptUtils.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/BananaScript/ScriptUtils.cpp b/BananaScript/ScriptUtils.cpp index 9c7a4e0..7f26d12 100644 --- a/BananaScript/ScriptUtils.cpp +++ b/BananaScript/ScriptUtils.cpp @@ -55,6 +55,7 @@ QScriptValue VariantToScriptValue( switch (variant.type()) { case QVariant::Map: + case QVariant::Hash: { auto vmap = variant.toMap(); @@ -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;