mirror of
https://github.com/Samsung/escargot.git
synced 2026-06-22 10:01:50 +00:00
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:
parent
8b72e1eb37
commit
ef57dc3400
13 changed files with 399 additions and 117 deletions
|
|
@ -40,12 +40,6 @@ OpcodeTable::OpcodeTable()
|
|||
ByteCodeInterpreter::interpret(state, &block, 0, nullptr, addr);
|
||||
}
|
||||
|
||||
// ECMA-262 11.3 Line Terminators
|
||||
ALWAYS_INLINE bool isLineTerminator(char16_t ch)
|
||||
{
|
||||
return (ch == 0x0A) || (ch == 0x0D) || (ch == 0x2028) || (ch == 0x2029);
|
||||
}
|
||||
|
||||
void* ByteCodeBlock::operator new(size_t size)
|
||||
{
|
||||
static bool typeInited = false;
|
||||
|
|
@ -115,7 +109,7 @@ ExtendedNodeLOC ByteCodeBlock::computeNodeLOC(StringView src, ExtendedNodeLOC so
|
|||
for (size_t i = 0; i < index && i < srcLength; i++) {
|
||||
char16_t c = src.charAt(i);
|
||||
column++;
|
||||
if (isLineTerminator(c)) {
|
||||
if (esprima::isLineTerminator(c)) {
|
||||
// skip \r\n
|
||||
if (c == 13 && (i + 1 < index) && src.charAt(i + 1) == 10) {
|
||||
i++;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue