Ignore:
Timestamp:
Sep 8, 2010, 2:59:24 AM (15 years ago)
Author:
[email protected]
Message:

Refactoring multiline comments in the lexer
https://bugs.webkit.org/show_bug.cgi?id=45289

Reviewed by Darin Adler.

MultiLine comment parsing is moved to a separate function.

Slight performance increase on --parse-only tests (from 33.6ms to 32.8ms)
SunSpider reports no change (from 523.1ms to 521.2ms).

  • parser/Lexer.cpp:

(JSC::Lexer::parseMultilineComment):
(JSC::Lexer::lex):

  • parser/Lexer.h:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/parser/Lexer.cpp

    r66375 r66962  
    676676}
    677677
     678ALWAYS_INLINE bool Lexer::parseMultilineComment()
     679{
     680    while (true) {
     681        while (UNLIKELY(m_current == '*')) {
     682            shift();
     683            if (m_current == '/') {
     684                shift();
     685                return true;
     686            }
     687        }
     688
     689        if (UNLIKELY(m_current == -1))
     690            return false;
     691
     692        if (isLineTerminator(m_current))
     693            shiftLineTerminator();
     694        else
     695            shift();
     696    }
     697}
     698
    678699JSTokenType Lexer::lex(JSTokenData* lvalp, JSTokenInfo* llocp, LexType lexType)
    679700{
     
    836857        if (m_current == '*') {
    837858            shift();
    838             goto inMultiLineComment;
     859            if (parseMultilineComment())
     860                goto start;
     861            goto returnError;
    839862        }
    840863        if (m_current == '=') {
     
    10291052    goto start;
    10301053
    1031 inMultiLineComment:
    1032     while (true) {
    1033         if (UNLIKELY(m_current == '*')) {
    1034             shift();
    1035             if (m_current == '/')
    1036                 break;
    1037             if (m_current == '*')
    1038                 continue;
    1039         }
    1040 
    1041         if (UNLIKELY(m_current == -1))
    1042             goto returnError;
    1043 
    1044         if (isLineTerminator(m_current))
    1045             shiftLineTerminator();
    1046         else
    1047             shift();
    1048     }
    1049     shift();
    1050     goto start;
    1051 
    10521054doneSemicolon:
    10531055    token = SEMICOLON;
Note: See TracChangeset for help on using the changeset viewer.