From 4554cdfdcbad336b49394bd534460a278cf1c9b4 Mon Sep 17 00:00:00 2001 From: Erik Verbruggen Date: Thu, 25 Oct 2012 09:15:11 +0200 Subject: [PATCH] Remove all is*Object methods. They differ from the isObject/isUndefined/etc. methods because they do an extra virtual function call. And with isObject and friends being cheap, is*Object methods could have made the same (but faulty) impression. Change-Id: I32f26a96e73251bd14f8198b0a1ffb5d59e53f31 Reviewed-by: Lars Knoll --- qmljs_runtime.cpp | 47 +---------------------------------------------- qmljs_runtime.h | 12 ------------ qv4ecmaobjects.cpp | 2 +- 3 files changed, 2 insertions(+), 59 deletions(-) diff --git a/qmljs_runtime.cpp b/qmljs_runtime.cpp index 1572e82..faae161 100644 --- a/qmljs_runtime.cpp +++ b/qmljs_runtime.cpp @@ -180,51 +180,6 @@ double Value::toInteger(double number) return std::signbit(number) ? -v : v; } -bool Value::isFunctionObject() const -{ - return isObject() ? objectValue()->asFunctionObject() != 0 : false; -} - -bool Value::isBooleanObject() const -{ - return isObject() ? objectValue()->asBooleanObject() != 0 : false; -} - -bool Value::isNumberObject() const -{ - return isObject() ? objectValue()->asNumberObject() != 0 : false; -} - -bool Value::isStringObject() const -{ - return isObject() ? objectValue()->asStringObject() != 0 : false; -} - -bool Value::isDateObject() const -{ - return isObject() ? objectValue()->asDateObject() != 0 : false; -} - -bool Value::isRegExpObject() const -{ - return isObject() ? objectValue()->asRegExpObject() != 0 : false; -} - -bool Value::isArrayObject() const -{ - return isObject() ? objectValue()->asArrayObject() != 0 : false; -} - -bool Value::isErrorObject() const -{ - return isObject() ? objectValue()->asErrorObject() != 0 : false; -} - -bool Value::isArgumentsObject() const -{ - return isObject() ? objectValue()->asActivationObject() != 0 : false; -} - Object *Value::asObject() const { return isObject() ? objectValue() : 0; @@ -937,7 +892,7 @@ Bool __qmljs_is_function(Value value) Value __qmljs_object_default_value(Context *ctx, Value object, int typeHint) { if (typeHint == PREFERREDTYPE_HINT) { - if (object.isDateObject()) + if (object.asDateObject()) typeHint = STRING_HINT; else typeHint = NUMBER_HINT; diff --git a/qmljs_runtime.h b/qmljs_runtime.h index 339bb48..bacde95 100644 --- a/qmljs_runtime.h +++ b/qmljs_runtime.h @@ -408,18 +408,6 @@ struct Value return b; } - - - bool isFunctionObject() const; - bool isBooleanObject() const; - bool isNumberObject() const; - bool isStringObject() const; - bool isDateObject() const; - bool isRegExpObject() const; - bool isArrayObject() const; - bool isErrorObject() const; - bool isArgumentsObject() const; - Object *asObject() const; FunctionObject *asFunctionObject() const; BooleanObject *asBooleanObject() const; diff --git a/qv4ecmaobjects.cpp b/qv4ecmaobjects.cpp index db97a43..ef211ea 100644 --- a/qv4ecmaobjects.cpp +++ b/qv4ecmaobjects.cpp @@ -2449,7 +2449,7 @@ void RegExpCtor::construct(Context *ctx) void RegExpCtor::call(Context *ctx) { - if (ctx->argumentCount > 0 && ctx->argument(0).isRegExpObject()) { + if (ctx->argumentCount > 0 && ctx->argument(0).asRegExpObject()) { if (ctx->argumentCount == 1 || ctx->argument(1).isUndefined()) { ctx->result = ctx->argument(0); return; -- 2.7.4