From 9b6e522a52e92d992f3e363164ca94392e8461e7 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Fri, 12 Apr 2013 15:03:16 +0200 Subject: Remove getValueChecked() In the two places where we need to check, we can do it more easily on the calling side. Change-Id: I259d3cc798660121bba13208ef46e371e3173053 Reviewed-by: Simon Hausmann --- src/v4/qv4jsonobject.cpp | 2 +- src/v4/qv4object.cpp | 14 +++++++------- src/v4/qv4object.h | 11 ----------- 3 files changed, 8 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/v4/qv4jsonobject.cpp b/src/v4/qv4jsonobject.cpp index 22cd8ea8d5..5282b7ea5c 100644 --- a/src/v4/qv4jsonobject.cpp +++ b/src/v4/qv4jsonobject.cpp @@ -785,7 +785,7 @@ QString Stringify::JO(Object *o) Property *pd = it.next(&name, &index, &attrs); if (!pd) break; - Value v = o->getValueChecked(ctx, pd, attrs); + Value v = o->getValue(ctx, pd, attrs); QString key; if (name) key = name->toQString(); diff --git a/src/v4/qv4object.cpp b/src/v4/qv4object.cpp index b68c8de8be..04eb74b41c 100644 --- a/src/v4/qv4object.cpp +++ b/src/v4/qv4object.cpp @@ -881,9 +881,8 @@ Value Object::arrayIndexOf(Value v, uint fromIndex, uint endIndex, ExecutionCont } } else if (sparseArray) { for (SparseArrayNode *n = sparseArray->lowerBound(fromIndex); n != sparseArray->end() && n->key() < endIndex; n = n->nextNode()) { - bool exists; - Value value = o->getValueChecked(ctx, arrayData + n->value, arrayAttributes ? arrayAttributes[n->value] : Attr_Data, &exists); - if (exists && __qmljs_strict_equal(value, v, ctx)) + Value value = o->getValue(ctx, arrayData + n->value, arrayAttributes ? arrayAttributes[n->value] : Attr_Data); + if (__qmljs_strict_equal(value, v, ctx)) return Value::fromDouble(n->key()); } } else { @@ -893,10 +892,11 @@ Value Object::arrayIndexOf(Value v, uint fromIndex, uint endIndex, ExecutionCont Property *end = pd + endIndex; pd += fromIndex; while (pd < end) { - bool exists; - Value value = o->getValueChecked(ctx, pd, arrayAttributes ? arrayAttributes[pd - arrayData] : Attr_Data, &exists); - if (exists && __qmljs_strict_equal(value, v, ctx)) - return Value::fromDouble(pd - arrayData); + if (!arrayAttributes || !arrayAttributes[pd - arrayData].isGeneric()) { + Value value = o->getValue(ctx, pd, arrayAttributes ? arrayAttributes[pd - arrayData] : Attr_Data); + if (__qmljs_strict_equal(value, v, ctx)) + return Value::fromDouble(pd - arrayData); + } ++pd; } } diff --git a/src/v4/qv4object.h b/src/v4/qv4object.h index f82f953970..a5ef09690c 100644 --- a/src/v4/qv4object.h +++ b/src/v4/qv4object.h @@ -155,17 +155,6 @@ struct Q_V4_EXPORT Object: Managed { Value getValue(ExecutionContext *ctx, const Property *p, PropertyAttributes attrs) const { return getValue(Value::fromObject(const_cast(this)), ctx, p, attrs); } - Value getValueChecked(ExecutionContext *ctx, const Property *p, PropertyAttributes attrs) const { - if (!p || attrs.isGeneric()) - return Value::undefinedValue(); - return getValue(Value::fromObject(const_cast(this)), ctx, p, attrs); - } - Value getValueChecked(ExecutionContext *ctx, const Property *p, PropertyAttributes attrs, bool *exists) const { - *exists = p && !attrs.isGeneric(); - if (!*exists) - return Value::undefinedValue(); - return getValue(Value::fromObject(const_cast(this)), ctx, p, attrs); - } void putValue(ExecutionContext *ctx, Property *pd, PropertyAttributes attrs, const Value &value); -- cgit v1.2.3