mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-04 05:20:30 +00:00
c0f985ffcf
The RegExpLiteral AST node already has the parsed regex::Parser::Result so let's plumb that over to the bytecode executable instead of reparsing the regex every time NewRegExp is executed. ~12% speed-up on language/literals/regexp/S7.8.5_A2.1_T2.js in test262.
29 lines
575 B
C++
29 lines
575 B
C++
/*
|
|
* Copyright (c) 2023, Andreas Kling <kling@serenityos.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#include <LibJS/Bytecode/RegexTable.h>
|
|
|
|
namespace JS::Bytecode {
|
|
|
|
RegexTableIndex RegexTable::insert(ParsedRegex regex)
|
|
{
|
|
m_regexes.append(move(regex));
|
|
return m_regexes.size() - 1;
|
|
}
|
|
|
|
ParsedRegex const& RegexTable::get(RegexTableIndex index) const
|
|
{
|
|
return m_regexes[index.value()];
|
|
}
|
|
|
|
void RegexTable::dump() const
|
|
{
|
|
outln("Regex Table:");
|
|
for (size_t i = 0; i < m_regexes.size(); i++)
|
|
outln("{}: {}", i, m_regexes[i].pattern);
|
|
}
|
|
|
|
}
|