Optimize ScriptParser more (#70)

* Diet ScannerResult
* Use SourceStringView if possible for reducing memory usage

Signed-off-by: seonghyun kim <sh8281.kim@samsung.com>
This commit is contained in:
김승현/Tizen Platform Lab(SR)/Engineer/삼성전자 2018-05-04 13:44:02 +09:00 committed by 최영일/Tizen Platform Lab(SR)/Principal Engineer/삼성전자
commit ef57dc3400
13 changed files with 399 additions and 117 deletions

View file

@ -415,7 +415,7 @@ ArrayObject* RegExpObject::createMatchedArray(ExecutionState& state, String* str
size_t len = result.m_matchResults.size();
ret->setThrowsException(state, state.context()->staticStrings().length, Value(len), ret);
for (size_t idx = 0; idx < len; idx++) {
ret->defineOwnProperty(state, ObjectPropertyName(state, Value(idx)), ObjectPropertyDescriptor(Value(StringView::createStringView(str, result.m_matchResults[idx][0].m_start, result.m_matchResults[idx][0].m_end)), ObjectPropertyDescriptor::AllPresent));
ret->defineOwnProperty(state, ObjectPropertyName(state, Value(idx)), ObjectPropertyDescriptor(Value(new StringView(str, result.m_matchResults[idx][0].m_start, result.m_matchResults[idx][0].m_end)), ObjectPropertyDescriptor::AllPresent));
}
return ret;
}
@ -433,7 +433,7 @@ ArrayObject* RegExpObject::createRegExpMatchedArray(ExecutionState& state, const
if (result.m_matchResults[i][j].m_start == std::numeric_limits<unsigned>::max()) {
arr->defineOwnPropertyThrowsException(state, ObjectPropertyName(state, Value(idx++)), ObjectPropertyDescriptor(Value(), ObjectPropertyDescriptor::AllPresent));
} else {
arr->defineOwnPropertyThrowsException(state, ObjectPropertyName(state, Value(idx++)), ObjectPropertyDescriptor(Value(StringView::createStringView(input, result.m_matchResults[i][j].m_start, result.m_matchResults[i][j].m_end)), ObjectPropertyDescriptor::AllPresent));
arr->defineOwnPropertyThrowsException(state, ObjectPropertyName(state, Value(idx++)), ObjectPropertyDescriptor(Value(new StringView(input, result.m_matchResults[i][j].m_start, result.m_matchResults[i][j].m_end)), ObjectPropertyDescriptor::AllPresent));
}
}
}