Short-circuit corpus scan
authorDuncan Beevers <duncan@dweebd.com>
Tue, 2 Sep 2014 13:12:20 +0000 (08:12 -0500)
committerDuncan Beevers <duncan@dweebd.com>
Tue, 2 Sep 2014 13:12:20 +0000 (08:12 -0500)
src/htmlparser.js

index a4447be..23f0f1d 100644 (file)
       if ( !stack.last() || !special[ stack.last() ] ) {
 
         // Comment:
-        if ( html.indexOf('<!--') === 0 ) {
+        if ( /^<!--/.test( html ) ) {
           index = html.indexOf('-->');
 
           if ( index >= 0 ) {
         }
 
         // http://en.wikipedia.org/wiki/Conditional_comment#Downlevel-revealed_conditional_comment
-        if ( html.indexOf('<![') === 0 ) {
+        if ( /^<!\[/.test( html ) ) {
           index = html.indexOf(']>');
 
           if (index >= 0) {
         }
 
         // End tag:
-        else if ( html.indexOf('</') === 0 ) {
+        else if ( /^<\//.test( html ) ) {
           match = html.match( endTag );
 
           if ( match ) {
 
         // Start tag:
         }
-        else if ( html.indexOf('<') === 0 ) {
+        else if ( /^</.test( html ) ) {
           match = html.match( startTag );
           if ( match ) {
             html = html.substring( match[0].length );