From 7c86f82527def11581d74e7e16594e74f8e04702 Mon Sep 17 00:00:00 2001 From: Jaeger Date: Fri, 13 Mar 2020 13:49:36 +0800 Subject: [PATCH] fix: optimize memory usage --- src/Dom/Query.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Dom/Query.php b/src/Dom/Query.php index 6e1cb11..c70b63b 100644 --- a/src/Dom/Query.php +++ b/src/Dom/Query.php @@ -9,6 +9,7 @@ namespace QL\Dom; use Tightenco\Collect\Support\Collection; use phpQuery; +use phpQueryObject; use QL\QueryList; use Closure; @@ -49,6 +50,7 @@ class Query public function setHtml($html, $charset = null) { $this->html = value($html); + $this->destroyDocument(); $this->document = phpQuery::newDocumentHTML($this->html,$charset); return $this->ql; } @@ -274,8 +276,9 @@ class Query protected function destroyDocument() { - $this->document->unloadDocument(); - unset($this->document); + if($this->document instanceof phpQueryObject) { + $this->document->unloadDocument(); + } } public function __destruct()