From 26db9863f18d7f7e89cec88b720e4fb4c674dd5b Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Sat, 2 Nov 2013 17:11:06 +0100 Subject: Optimise string additions Small optimisation for string additions, also add one more check for exceptions in the code where required. Change-Id: I6c14bc88ea5d03f7eeed0e0168c5195f9f823693 Reviewed-by: Simon Hausmann --- src/qml/jsruntime/qv4regexpobject.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/qml/jsruntime/qv4regexpobject.cpp') diff --git a/src/qml/jsruntime/qv4regexpobject.cpp b/src/qml/jsruntime/qv4regexpobject.cpp index 7322a58412..c2d04cc7ed 100644 --- a/src/qml/jsruntime/qv4regexpobject.cpp +++ b/src/qml/jsruntime/qv4regexpobject.cpp @@ -266,10 +266,10 @@ ReturnedValue RegExpCtor::construct(Managed *m, CallData *callData) bool ignoreCase = false; bool multiLine = false; if (!f->isUndefined()) { - f = __qmljs_to_string(f, ctx); - QString str = f->stringValue()->toQString(); + f = __qmljs_to_string(ctx, f); if (scope.hasException()) return Encode::undefined(); + QString str = f->stringValue()->toQString(); for (int i = 0; i < str.length(); ++i) { if (str.at(i) == QLatin1Char('g') && !global) { global = true; @@ -322,7 +322,9 @@ ReturnedValue RegExpPrototype::method_exec(SimpleCallContext *ctx) return ctx->throwTypeError(); ScopedValue arg(scope, ctx->argument(0)); - arg = __qmljs_to_string(arg, ctx); + arg = __qmljs_to_string(ctx, arg); + if (scope.hasException()) + return Encode::undefined(); QString s = arg->stringValue()->toQString(); int offset = r->global ? r->lastIndexProperty(ctx)->value.toInt32() : 0; -- cgit v1.2.3