X-Git-Url: https://git.saurik.com/apple/javascriptcore.git/blobdiff_plain/f9bf01c6616d5ddcf65b13b33cedf9e387ff7a63..fb8617cde5834786bd4e4afd579883e4acf5666e:/parser/Lexer.cpp?ds=sidebyside diff --git a/parser/Lexer.cpp b/parser/Lexer.cpp index 83f56bd..682edb6 100644 --- a/parser/Lexer.cpp +++ b/parser/Lexer.cpp @@ -1025,20 +1025,23 @@ SourceCode Lexer::sourceCode(int openBrace, int closeBrace, int firstLine) return SourceCode(m_source->provider(), openBrace, closeBrace + 1, firstLine); const UChar* data = m_source->provider()->data(); - + ASSERT(openBrace < closeBrace); - - int numBOMsBeforeOpenBrace = 0; - int numBOMsBetweenBraces = 0; - int i; - for (i = m_source->startOffset(); i < openBrace; ++i) - numBOMsBeforeOpenBrace += data[i] == byteOrderMark; - for (; i < closeBrace; ++i) - numBOMsBetweenBraces += data[i] == byteOrderMark; + for (i = m_source->startOffset(); i < openBrace; ++i) { + if (data[i] == byteOrderMark) { + openBrace++; + closeBrace++; + } + } + for (; i < closeBrace; ++i) { + if (data[i] == byteOrderMark) + closeBrace++; + } + + ASSERT(openBrace < closeBrace); - return SourceCode(m_source->provider(), openBrace + numBOMsBeforeOpenBrace, - closeBrace + numBOMsBeforeOpenBrace + numBOMsBetweenBraces + 1, firstLine); + return SourceCode(m_source->provider(), openBrace, closeBrace + 1, firstLine); } } // namespace JSC