diff options
author | Lars Knoll <lars.knoll@digia.com> | 2013-08-27 14:41:47 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-09-02 17:27:36 +0200 |
commit | 4a5e32f4f7221be5fc5ab79d5283ce89f7ccbeae (patch) | |
tree | 7b5cc4b15619449e1916dbbb8eff0916208774a9 /src | |
parent | 819b4ef8b1e196596b4f56cb0d729f6b5fa93b0b (diff) |
Add Value::isNullOrUndefined()
Allows for some smaller optimization in the call stack.
Change-Id: Id5beeb04e9f9dbf9e61280cee7bf6758a4c02310
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/qml/jsruntime/qv4functionobject.cpp | 6 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4value_def_p.h | 2 |
2 files changed, 5 insertions, 3 deletions
diff --git a/src/qml/jsruntime/qv4functionobject.cpp b/src/qml/jsruntime/qv4functionobject.cpp index a4533edc9c..995434aca2 100644 --- a/src/qml/jsruntime/qv4functionobject.cpp +++ b/src/qml/jsruntime/qv4functionobject.cpp @@ -275,7 +275,7 @@ Value FunctionPrototype::method_apply(SimpleCallContext *ctx) Object *arr = arg.asObject(); if (!arr) { - if (!(arg.isUndefined() || arg.isNull())) { + if (!arg.isNullOrUndefined()) { ctx->throwTypeError(); return Value::undefinedValue(); } @@ -404,7 +404,7 @@ Value ScriptFunction::call(Managed *that, const CallData &d) ExecutionContext *ctx = context->newCallContext(f, d); if (!f->strictMode && !d.thisObject.isObject()) { - if (d.thisObject.isUndefined() || d.thisObject.isNull()) { + if (d.thisObject.isNullOrUndefined()) { ctx->thisObject = Value::fromObject(f->engine()->globalObject); } else { ctx->thisObject = Value::fromObject(d.thisObject.toObject(context)); @@ -499,7 +499,7 @@ Value SimpleScriptFunction::call(Managed *that, const CallData &d) ExecutionContext *ctx = context->newCallContext(stackSpace, f, d); if (!f->strictMode && !d.thisObject.isObject()) { - if (d.thisObject.isUndefined() || d.thisObject.isNull()) { + if (d.thisObject.isNullOrUndefined()) { ctx->thisObject = Value::fromObject(f->engine()->globalObject); } else { ctx->thisObject = Value::fromObject(d.thisObject.toObject(context)); diff --git a/src/qml/jsruntime/qv4value_def_p.h b/src/qml/jsruntime/qv4value_def_p.h index a44af16b6a..7d037f3d49 100644 --- a/src/qml/jsruntime/qv4value_def_p.h +++ b/src/qml/jsruntime/qv4value_def_p.h @@ -80,6 +80,7 @@ struct Q_QML_EXPORT Value Type_Mask = 0xffff8000, Immediate_Mask = NotDouble_Mask | 0x00008000, IsManaged_Mask = Type_Mask & ~0x10000, + IsNullOrUndefined_Mask = Immediate_Mask | 0x20000, Tag_Shift = 32 }; enum ValueType { @@ -128,6 +129,7 @@ struct Q_QML_EXPORT Value inline bool isObject() const { return tag == Object_Type; } #endif inline bool isManaged() const { return (tag & IsManaged_Mask) == Object_Type; } + inline bool isNullOrUndefined() const { return (tag & IsNullOrUndefined_Mask) == Undefined_Type; } inline bool isConvertibleToInt() const { return (tag & ConvertibleToInt) == ConvertibleToInt; } inline bool isInt32() { if (tag == _Integer_Type) |