fix: optimize memory usage
This commit is contained in:
parent
6ee6a26aee
commit
7c86f82527
@ -9,6 +9,7 @@ namespace QL\Dom;
|
|||||||
|
|
||||||
use Tightenco\Collect\Support\Collection;
|
use Tightenco\Collect\Support\Collection;
|
||||||
use phpQuery;
|
use phpQuery;
|
||||||
|
use phpQueryObject;
|
||||||
use QL\QueryList;
|
use QL\QueryList;
|
||||||
use Closure;
|
use Closure;
|
||||||
|
|
||||||
@ -49,6 +50,7 @@ class Query
|
|||||||
public function setHtml($html, $charset = null)
|
public function setHtml($html, $charset = null)
|
||||||
{
|
{
|
||||||
$this->html = value($html);
|
$this->html = value($html);
|
||||||
|
$this->destroyDocument();
|
||||||
$this->document = phpQuery::newDocumentHTML($this->html,$charset);
|
$this->document = phpQuery::newDocumentHTML($this->html,$charset);
|
||||||
return $this->ql;
|
return $this->ql;
|
||||||
}
|
}
|
||||||
@ -274,8 +276,9 @@ class Query
|
|||||||
|
|
||||||
protected function destroyDocument()
|
protected function destroyDocument()
|
||||||
{
|
{
|
||||||
$this->document->unloadDocument();
|
if($this->document instanceof phpQueryObject) {
|
||||||
unset($this->document);
|
$this->document->unloadDocument();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function __destruct()
|
public function __destruct()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user