Ignore:
Timestamp:
Apr 1, 2011, 10:36:14 AM (14 years ago)
Author:
Adam Roben
Message:

Maintain the invariant that Lexer::m_current is set to -1 when at the end of the code buffer

Covered by existing tests.

Fixes <http://webkit.org/b/56699>.

Reviewed by Oliver Hunt.

  • parser/Lexer.h:

(JSC::Lexer::setOffset): Copied code from Lexer::shift to update m_current, because
supposedly the idiom that function uses is fast.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/parser/Lexer.h

    r76248 r82696  
    7272            m_error = 0;
    7373            m_code = m_codeStart + offset;
    74             m_current = *m_code;
    7574            m_buffer8.resize(0);
    7675            m_buffer16.resize(0);
    77             if (UNLIKELY(m_code == m_codeEnd))
    78                 m_current = -1;
     76            // Faster than an if-else sequence
     77            m_current = -1;
     78            if (LIKELY(m_code < m_codeEnd))
     79                m_current = *m_code;
    7980        }
    8081        void setLineNumber(int line)
Note: See TracChangeset for help on using the changeset viewer.