[CLEANUP] Replace strlen() with === for zero length check

It is faster to compare a string with === '' to find out if it's empty
than to run strlen() on it.

The replacement rules are applied as follows:
 *    if (strlen($str))
   => if ((string)$str !== '')
 *    if (!is_string($str) || strlen($str) === 0)
   => if (!is_string($str) || $str === '')
 * If it can be seen easily that $str is a string,
   the typecast is omitted.

Resolves: #54091
Releases: 6.2
Change-Id: I59c5cbccea4f98b8f282377e6aa67d970859a457
Reviewed-on: https://review.typo3.org/27091
Reviewed-by: Stefan Neufeind
Tested-by: Stefan Neufeind
This commit is contained in:
Markus Klein 2014-02-23 11:21:20 +01:00 committed by Stefan Neufeind
parent 7e04633b0d
commit 36db0437f7

View file

@ -196,7 +196,9 @@ class FrontendEditPanel {
$cBuf = rtrim(preg_replace('/<[^<]*>$/', '', $cBuf)); $cBuf = rtrim(preg_replace('/<[^<]*>$/', '', $cBuf));
$secureCount--; $secureCount--;
} }
$content = strlen($cBuf) && $secureCount ? substr($content, 0, strlen($cBuf)) . $icon . substr($content, strlen($cBuf)) : ($content = $icon . $content); $content = $cBuf !== '' && $secureCount
? substr($content, 0, strlen($cBuf)) . $icon . substr($content, strlen($cBuf))
: $icon . $content;
} else { } else {
$content .= $icon; $content .= $icon;
} }