From: Paul R. <pri...@us...> - 2005-12-06 23:48:00
|
Update of /cvsroot/mantisbt/mantisbt/core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4691 Modified Files: string_api.php Log Message: Optimise string_restore_valid_html_tags: Number of Tests: 100000 Old Result: 35.850841999054 New Result: 14.799801826477 Index: string_api.php =================================================================== RCS file: /cvsroot/mantisbt/mantisbt/core/string_api.php,v retrieving revision 1.76 retrieving revision 1.77 diff -u -d -r1.76 -r1.77 --- string_api.php 5 Dec 2005 12:17:55 -0000 1.76 +++ string_api.php 6 Dec 2005 23:47:51 -0000 1.77 @@ -396,15 +396,16 @@ } $tags = explode( ',', $t_html_valid_tags ); + foreach ($tags as $key => $value) { + if ( !is_blank( $value ) ) { + $tags[$key] = trim($value); + } + } + $tags = implode( '|', $tags); - foreach ( $tags as $tag ) { - if ( !is_blank( $tag ) ) { - $tag = trim( $tag ); - $p_string = eregi_replace( "<($tag)[[:space:]]*>", "<\\1>", $p_string ); - $p_string = eregi_replace( "<\/($tag)[[:space:]]*>", "</\\1>", $p_string ); - $p_string = eregi_replace( "<($tag)[[:space:]]*\/>", "<\\1 />", $p_string ); - } - } + $p_string = eregi_replace( '<(' . $tags . ')[[:space:]]*>', '<\\1>', $p_string ); + $p_string = eregi_replace( '<\/(' .$tags . ')[[:space:]]*>', '</\\1>', $p_string ); + $p_string = eregi_replace( '<(' . $tags . ')[[:space:]]*\/>', '<\\1 />', $p_string ); return $p_string; } |