A little perf and memory enhancement when building category tree

This commit is contained in:
Laurent Destailleur 2020-08-07 15:47:02 +02:00
parent 3c6f122a81
commit 9876e37309

View File

@ -1213,7 +1213,8 @@ class Categorie extends CommonObject
//print 'Result for id_categ='.$id_categ.' : '.$this->cats[$id_categ]['fullpath'].'<br>'."\n";
// We count number of _ to have level
$this->cats[$id_categ]['level'] = dol_strlen(preg_replace('/[^_]/i', '', $this->cats[$id_categ]['fullpath']));
$nbunderscore = substr_count($this->cats[$id_categ]['fullpath'], '_');
$this->cats[$id_categ]['level'] = ($nbunderscore ? $nbunderscore : null);
return;
}