1
0
mirror of https://github.com/ezyang/htmlpurifier.git synced 2025-08-06 06:07:26 +02:00

[3.1.0] Convert tokens to use instanceof, reducing memory footprint and improving comparison speed.

git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@1509 48356398-32a2-884e-a903-53898d9a118a
This commit is contained in:
Edward Z. Yang
2008-01-19 20:23:01 +00:00
parent dd8ef4d3f5
commit 5eee08c548
16 changed files with 78 additions and 70 deletions

View File

@@ -71,9 +71,9 @@ class HTMLPurifier_ChildDef_Required extends HTMLPurifier_ChildDef
$is_child = ($nesting == 0);
if ($token->type == 'start') {
if ($token instanceof HTMLPurifier_Token_Start) {
$nesting++;
} elseif ($token->type == 'end') {
} elseif ($token instanceof HTMLPurifier_Token_End) {
$nesting--;
}
@@ -81,7 +81,7 @@ class HTMLPurifier_ChildDef_Required extends HTMLPurifier_ChildDef
$is_deleting = false;
if (!isset($this->elements[$token->name])) {
$is_deleting = true;
if ($pcdata_allowed && $token->type == 'text') {
if ($pcdata_allowed && $token instanceof HTMLPurifier_Token_Text) {
$result[] = $token;
} elseif ($pcdata_allowed && $escape_invalid_children) {
$result[] = new HTMLPurifier_Token_Text(
@@ -91,7 +91,7 @@ class HTMLPurifier_ChildDef_Required extends HTMLPurifier_ChildDef
continue;
}
}
if (!$is_deleting || ($pcdata_allowed && $token->type == 'text')) {
if (!$is_deleting || ($pcdata_allowed && $token instanceof HTMLPurifier_Token_Text)) {
$result[] = $token;
} elseif ($pcdata_allowed && $escape_invalid_children) {
$result[] =