Optimise callProperty for Strings.
authorLars Knoll <lars.knoll@digia.com>
Tue, 29 Jan 2013 21:07:48 +0000 (22:07 +0100)
committerSimon Hausmann <simon.hausmann@digia.com>
Tue, 29 Jan 2013 23:25:01 +0000 (00:25 +0100)
Don't convert the String to a StringOject, just to
call a method on it's prototype. The result would
in any case be the same.

Change-Id: I74cea392b20b6c5642d010287ebf6e27c91eea83
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
qmljs_runtime.cpp

index 682f025..9e50217 100644 (file)
@@ -45,6 +45,7 @@
 #include "qv4ir_p.h"
 #include "qv4objectproto.h"
 #include "qv4globalobject.h"
+#include "qv4stringobject.h"
 #include "private/qlocale_tools_p.h"
 
 #include <QtCore/qmath.h>
@@ -747,14 +748,18 @@ Value __qmljs_call_activation_property(ExecutionContext *context, String *name,
     return o->call(context, thisObject, args, argc);
 }
 
-Value __qmljs_call_property(ExecutionContext *context, Value that, String *name, Value *args, int argc)
+Value __qmljs_call_property(ExecutionContext *context, Value thisObject, String *name, Value *args, int argc)
 {
-    Value thisObject = that;
-    if (!thisObject.isObject())
-        thisObject = __qmljs_to_object(thisObject, context);
+    Object *baseObject;
+    if (thisObject.isString()) {
+        baseObject = context->engine->stringPrototype;
+    } else {
+        if (!thisObject.isObject())
+            thisObject = __qmljs_to_object(thisObject, context);
 
-    assert(thisObject.isObject());
-    Object *baseObject = thisObject.objectValue();
+        assert(thisObject.isObject());
+       baseObject = thisObject.objectValue();
+    }
 
     Value func = baseObject->__get__(context, name);
     FunctionObject *o = func.asFunctionObject();