Refactor code (#396)

* Revise hasProperty and apply it everywhere
* Add hasIndexedProperty for performance
* Change Object::nextIndex{Forward, Backward} double parameter types into int for performance
* in String.prototype.replace, Use test fast path correctly & use old method because newer method cannot support regexp correctly(old method is faster)

Signed-off-by: seonghyun kim <sh8281.kim@samsung.com>
This commit is contained in:
Patrick Kim 2019-08-29 14:35:50 +09:00 committed by Hyukwoo Park
commit b656248ce4
17 changed files with 511 additions and 242 deletions

View file

@ -100,6 +100,18 @@ ObjectGetResult StringObject::getIndexedProperty(ExecutionState& state, const Va
return get(state, ObjectPropertyName(state, property));
}
ObjectHasPropertyResult StringObject::hasIndexedProperty(ExecutionState& state, const Value& propertyName)
{
Value::ValueIndex idx = propertyName.tryToUseAsIndex(state);
if (idx != Value::InvalidIndexValue) {
size_t strLen = m_primitiveValue->length();
if (LIKELY(idx < strLen)) {
return ObjectHasPropertyResult(ObjectGetResult(Value(String::fromCharCode(m_primitiveValue->charAt(idx))), false, true, false));
}
}
return hasProperty(state, ObjectPropertyName(state, propertyName));
}
StringIteratorObject::StringIteratorObject(ExecutionState& state, String* s)
: IteratorObject(state)
, m_string(s)