Skip to content

Commit 17ac781

Browse files
committed
Performance optimizations.
1 parent ad8651a commit 17ac781

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/HTMLServerComponentsCompiler.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ class HTMLServerComponentsCompiler
2727
*/
2828
private $aliases = [];
2929

30+
/**
31+
*
32+
*/
33+
private static $newComponentCache = null;
34+
3035
/**
3136
* Adds an alias
3237
*
@@ -156,7 +161,10 @@ public function process(string $content, array $options = [])
156161
*/
157162
public function constructComponent(array $attributes = [], string $innerHTML = '')
158163
{
159-
$component = new \IvoPetkov\HTMLServerComponent();
164+
if (self::$newComponentCache === null) {
165+
self::$newComponentCache = new \IvoPetkov\HTMLServerComponent();
166+
}
167+
$component = clone(self::$newComponentCache);
160168
$component->attributes = $attributes;
161169
$component->innerHTML = $innerHTML;
162170
return $component;

0 commit comments

Comments
 (0)