From 366af48be47c97150bc93dfdeb82171f8c3e0b6b Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Mon, 12 Apr 2021 19:30:02 +0200 Subject: [PATCH] Inline calls in `removeNode()` to improve the simplified-html/plain performance --- wcfsetup/install/files/lib/util/DOMUtil.class.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/wcfsetup/install/files/lib/util/DOMUtil.class.php b/wcfsetup/install/files/lib/util/DOMUtil.class.php index 238d5a1f24..f362bb9362 100644 --- a/wcfsetup/install/files/lib/util/DOMUtil.class.php +++ b/wcfsetup/install/files/lib/util/DOMUtil.class.php @@ -478,6 +478,8 @@ final class DOMUtil { * @param boolean $preserveChildNodes preserve child nodes, only supported for elements */ public static function removeNode(\DOMNode $node, $preserveChildNodes = false) { + $parent = $node->parentNode ?: $node->ownerDocument; + if ($preserveChildNodes) { if (!($node instanceof \DOMElement)) { throw new \InvalidArgumentException("Preserving child nodes is only supported for DOMElement."); @@ -489,11 +491,11 @@ final class DOMUtil { } foreach ($children as $child) { - self::insertBefore($child, $node); + $parent->insertBefore($child, $node); } } - self::getParentNode($node)->removeChild($node); + $parent->removeChild($node); } /** -- 2.20.1