fix: optimize memory usage

This commit is contained in:
Jaeger 2020-03-13 13:49:36 +08:00
parent 6ee6a26aee
commit 7c86f82527

View File

@ -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()
{
if($this->document instanceof phpQueryObject) {
$this->document->unloadDocument();
unset($this->document);
}
}
public function __destruct()