diff options
author | Lars Knoll <lars.knoll@qt.io> | 2017-11-07 13:45:28 +0100 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2017-11-15 18:47:03 +0000 |
commit | 1a3464f232e35a0570eb810022bb8326c846d24b (patch) | |
tree | cb39ec27fb5c24a007e2bfed41a3c166f1b05e47 | |
parent | ae1b7bf75705962f361b34a352094e7006ccde8a (diff) |
Optimize Value::toObject/toString
Change-Id: Iccfe50c967560deee9e2903bbe3a293b13fe8b48
Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
-rw-r--r-- | src/qml/jsruntime/qv4value.cpp | 4 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4value_p.h | 4 |
2 files changed, 4 insertions, 4 deletions
diff --git a/src/qml/jsruntime/qv4value.cpp b/src/qml/jsruntime/qv4value.cpp index e7aaa97e6b..0d4711df3c 100644 --- a/src/qml/jsruntime/qv4value.cpp +++ b/src/qml/jsruntime/qv4value.cpp @@ -238,15 +238,11 @@ bool Value::sameValue(Value other) const { #ifndef V4_BOOTSTRAP Heap::String *Value::toString(ExecutionEngine *e, Value val) { - if (String *s = val.stringValue()) - return s->d(); return RuntimeHelpers::convertToString(e, val); } Heap::Object *Value::toObject(ExecutionEngine *e, Value val) { - if (Object *o = val.objectValue()) - return o->d(); return RuntimeHelpers::convertToObject(e, val); } diff --git a/src/qml/jsruntime/qv4value_p.h b/src/qml/jsruntime/qv4value_p.h index 0608252082..14ef62da36 100644 --- a/src/qml/jsruntime/qv4value_p.h +++ b/src/qml/jsruntime/qv4value_p.h @@ -428,10 +428,14 @@ public: QString toQStringNoThrow() const; QString toQString() const; Heap::String *toString(ExecutionEngine *e) const { + if (isString()) + return reinterpret_cast<Heap::String *>(m()); return toString(e, *this); } static Heap::String *toString(ExecutionEngine *e, Value val); Heap::Object *toObject(ExecutionEngine *e) const { + if (isObject()) + return reinterpret_cast<Heap::Object *>(m()); return toObject(e, *this); } static Heap::Object *toObject(ExecutionEngine *e, Value val); |