mirror of
https://github.com/Samsung/escargot.git
synced 2026-06-29 10:02:14 +00:00
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:
parent
393792cae7
commit
b656248ce4
17 changed files with 511 additions and 242 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue