diff options
author | Lars Knoll <lars.knoll@digia.com> | 2013-11-02 15:01:09 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-11-04 15:01:30 +0100 |
commit | 751ec14a5c5332d7ce8a057da853cc809fe2991a (patch) | |
tree | 3e4ffbbb8117a4157302931bf940afa14470730b /src/qml/qml/qqmllocale.cpp | |
parent | 960d473f15c9cfc7bf73bb3b4dc0e4494a7dbe92 (diff) |
Better way of handling string additions
The old algorithm still had some quadratic behavior when adding
strings in a loop. This fixes is by keeping track of the longest
substring used, as well as the length of the string. If the length
is larger then twice the length of the longest substring, we
simplify the string.
Change-Id: I9d99ae1632a8046ac135e67bdbb448638d15836d
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src/qml/qml/qqmllocale.cpp')
-rw-r--r-- | src/qml/qml/qqmllocale.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/qml/qml/qqmllocale.cpp b/src/qml/qml/qqmllocale.cpp index 81a6ffc590..b92b3e4c2c 100644 --- a/src/qml/qml/qqmllocale.cpp +++ b/src/qml/qml/qqmllocale.cpp @@ -437,7 +437,7 @@ QV4::ReturnedValue QQmlNumberExtension::method_toLocaleString(QV4::SimpleCallCon if (!ctx->callData->args[1].isString()) V4THROW_ERROR("Locale: Number.toLocaleString(): Invalid arguments"); QV4::String *fs = ctx->callData->args[1].toString(ctx); - if (!fs->isEmpty()) + if (fs->length()) format = fs->toQString().at(0).unicode(); } int prec = 2; @@ -501,7 +501,7 @@ QV4::ReturnedValue QQmlNumberExtension::method_fromLocaleString(QV4::SimpleCallC } QV4::String *ns = ctx->callData->args[numberIdx].toString(ctx); - if (ns->isEmpty()) + if (!ns->length()) return QV4::Encode(Q_QNAN); bool ok = false; |