[Vtigercrm-developers] performance and profiling
Alan Bell
alan.bell at libertus.co.uk
Fri Jul 18 13:04:05 GMT 2014
turns out that most of what to_html is processing is very repetitive, if
it just populates an array as it goes along and then checks in that
array it is a lot faster than doing htmlentities on the string every time.
global $htmlcache;//store the stripped HTML as we go along, a lot of the
time we are processing the same strings
function to_html($string, $encode=true)
{
global $doconvert;
global $default_charset;
global $htmlcache;
if($doconvert){
if(isset($htmlcache[$string])){
return $htmlcache[$string];
}else{
$clean= htmlentities($string, ENT_QUOTES,
$default_charset);//we don't care if it is a string or not, faster not
to care
$htmlcache[$string]=$clean;
return $clean;
}
}else{
return $string;
}
}
More information about the vtigercrm-developers
mailing list