Esempio n. 1
0
 /**
  * Merges adjacent Text children of the specified container whenever that merge can be safely done.
  *
  * > Note: Although the parser doesn't generate redundant literals, they may occur after macro substitutions are
  * performed.
  *
  * @param Component $c The container component.
  */
 private function text_optimize(Component $c)
 {
     $o = [];
     $prev = null;
     if ($c->hasChildren()) {
         foreach ($c->getChildren() as $child) {
             if ($prev && $prev instanceof Text && !$prev->getBindings() && $child instanceof Text && !$child->getBindings()) {
                 // safe to merge
                 $prev->props->value .= $child->props->value;
                 continue;
             }
             $o[] = $child;
             $prev = $child;
         }
     }
     $c->setChildren($o);
 }