X-Git-Url: https://git.saurik.com/apple/javascriptcore.git/blobdiff_plain/fb8617cde5834786bd4e4afd579883e4acf5666e..4e4e5a6f2694187498445a6ac6f1634ce8141119:/parser/Lexer.cpp?ds=inline diff --git a/parser/Lexer.cpp b/parser/Lexer.cpp index 682edb6..bdeb049 100644 --- a/parser/Lexer.cpp +++ b/parser/Lexer.cpp @@ -52,8 +52,6 @@ Lexer::Lexer(JSGlobalData* globalData) , m_globalData(globalData) , m_keywordTable(JSC::mainTable) { - m_buffer8.reserveInitialCapacity(initialReadBufferCapacity); - m_buffer16.reserveInitialCapacity(initialReadBufferCapacity); } Lexer::~Lexer() @@ -149,6 +147,9 @@ void Lexer::setCode(const SourceCode& source, ParserArena& arena) m_error = false; m_atLineStart = true; + m_buffer8.reserveInitialCapacity(initialReadBufferCapacity); + m_buffer16.reserveInitialCapacity((m_codeEnd - m_code) / 2); + // ECMA-262 calls for stripping all Cf characters, but we only strip BOM characters. // See for details. if (source.provider()->hasBOMs()) { @@ -1009,11 +1010,9 @@ void Lexer::clear() m_codeWithoutBOMs.clear(); Vector newBuffer8; - newBuffer8.reserveInitialCapacity(initialReadBufferCapacity); m_buffer8.swap(newBuffer8); Vector newBuffer16; - newBuffer16.reserveInitialCapacity(initialReadBufferCapacity); m_buffer16.swap(newBuffer16); m_isReparsing = false;