]> git.saurik.com Git - apple/javascriptcore.git/blobdiff - parser/Lexer.cpp
JavaScriptCore-584.tar.gz
[apple/javascriptcore.git] / parser / Lexer.cpp
index 83f56bd244bb5f0e9c172efce957e99b8893787e..682edb6a03ef039a25730acc4d8342162cde2996 100644 (file)
@@ -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