Skip to content

Commit

Permalink
improved Mojo::DOM::HTML performance slightly
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Jul 15, 2014
1 parent 7176ed7 commit 502e791
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 23 deletions.
1 change: 1 addition & 0 deletions Changes
@@ -1,5 +1,6 @@

5.15 2014-07-15
- Improved Mojo::DOM::HTML performance slightly.

5.14 2014-07-14
- Improved all_text performance in Mojo::DOM.
Expand Down
5 changes: 1 addition & 4 deletions lib/Mojo/DOM/CSS.pm
Expand Up @@ -27,10 +27,7 @@ my $TOKEN_RE = qr/
((?:[^[\\:\s,]|$ESCAPE_RE\s?)+)? # Element
($PSEUDO_CLASS_RE*)? # Pseudoclass
((?:$ATTR_RE)*)? # Attributes
(?:
\s*
([>+~]) # Combinator
)?
(?:\s*([>+~]))? # Combinator
/x;

sub match {
Expand Down
40 changes: 21 additions & 19 deletions lib/Mojo/DOM/HTML.pm
Expand Up @@ -22,29 +22,31 @@ my $ATTR_RE = qr/
\s*
/x;
my $TOKEN_RE = qr/
([^<]+)? # Text
([^<]+)? # Text
(?:
<\?(.*?)\?> # Processing Instruction
|
<!--(.*?)--\s*> # Comment
|
<!\[CDATA\[(.*?)\]\]> # CDATA
|
<!DOCTYPE(
\s+\w+
(?:(?:\s+\w+)?(?:\s+(?:"[^"]*"|'[^']*'))+)? # External ID
(?:\s+\[.+?\])? # Int Subset
\s*
)>
|
<(
\s*
[^<>\s]+ # Tag
<(?:
\?(.*?)\? # Processing Instruction
|
!(?:
--(.*?)--\s* # Comment
|
\[CDATA\[(.*?)\]\] # CDATA
|
DOCTYPE(
\s+\w+ # Doctype
(?:(?:\s+\w+)?(?:\s+(?:"[^"]*"|'[^']*'))+)? # External ID
(?:\s+\[.+?\])? # Int Subset
\s*)
)
|
(\s*
[^<>\s]+ # Tag
\s*
(?:(?:$ATTR_RE){0,32766})*+ # Attributes
(?:(?:$ATTR_RE){0,32766})*+ # Attributes
)
)>
|
(<) # Runaway "<"
(<) # Runaway "<"
)??
/xis;

Expand Down

0 comments on commit 502e791

Please sign in to comment.