Skip to content

Commit

Permalink
no need to check XML status for every tag
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Jan 31, 2014
1 parent 9b840f9 commit 92c4bdc
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/Mojo/DOM/HTML.pm
Expand Up @@ -21,7 +21,7 @@ my $ATTR_RE = qr/
)?
\s*
/x;
my $END_RE = qr!^\s*/\s*(.+)\s*!;
my $END_RE = qr!^\s*/\s*(.+)!;
my $TOKEN_RE = qr/
([^<]+)? # Text
(?:
Expand Down Expand Up @@ -89,6 +89,7 @@ my %PHRASING = map { $_ => 1 } @OBSOLETE, @PHRASING;
sub parse {
my ($self, $html) = @_;

my $xml = $self->xml;
my $current = my $tree = ['root'];
while ($html =~ m/\G$TOKEN_RE/gcs) {
my ($text, $pi, $comment, $cdata, $doctype, $tag, $runaway)
Expand All @@ -102,7 +103,6 @@ sub parse {
if (defined $tag) {

# End
my $xml = $self->xml;
if ($tag =~ $END_RE) { _end($xml ? $1 : lc($1), $xml, \$current) }

# Start
Expand Down Expand Up @@ -145,7 +145,7 @@ sub parse {

# Processing instruction (try to detect XML)
elsif (defined $pi) {
$self->xml(1) if !exists $self->{xml} && $pi =~ /xml/i;
$self->xml($xml = 1) if !exists $self->{xml} && $pi =~ /xml/i;
push @$current, ['pi', $pi];
}
}
Expand Down

0 comments on commit 92c4bdc

Please sign in to comment.