8000 Optimized some strlen() calls when possible · symfony/symfony@53aaa9e · GitHub
[go: up one dir, main page]

Skip to content

Commit 53aaa9e

Browse files
committed
Optimized some strlen() calls when possible
1 parent 290f76f commit 53aaa9e

File tree

5 files changed

+7
-7
lines changed

5 files changed

+7
-7
lines changed

src/Symfony/Component/Config/Definition/ArrayNode.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ public function getDefaultValue()
192192
public function addChild(NodeInterface $node)
193193
{
194194
$name = $node->getName();
195-
if (!\strlen($name)) {
195+
if ('' === $name) {
196196
throw new \InvalidArgumentException('Child nodes must be named.');
197197
}
198198
if (isset($this->children[$name])) {

src/Symfony/Component/Console/Helper/QuestionHelper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ private function mostRecentlyEnteredValue(string $entered): string
382382
}
383383

384384
$choices = explode(',', $entered);
385-
if (\strlen($lastChoice = trim($choices[\count($choices) - 1])) > 0) {
385+
if ('' !== $lastChoice = trim($choices[\count($choices) - 1])) {
386386
return $lastChoice;
387387
}
388388

src/Symfony/Component/Console/Input/StringInput.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ private function tokenize(string $input): array
5050
while ($cursor < $length) {
5151
if (preg_match('/\s+/A', $input, $match, 0, $cursor)) {
5252
} elseif (preg_match('/([^="\'\s]+?)(=?)('.self::REGEX_QUOTED_STRING.'+)/A', $input, $match, 0, $cursor)) {
53-
$tokens[] = $match[1].$match[2].stripcslashes(str_replace(['"\'', '\'"', '\'\'', '""'], '', substr($match[3], 1, \strlen($match[3]) - 2)));
53+
$tokens[] = $match[1].$match[2].stripcslashes(str_replace(['"\'', '\'"', '\'\'', '""'], '', substr($match[3], 1, -1)));
5454
} elseif (preg_match('/'.self::REGEX_QUOTED_STRING.'/A', $input, $match, 0, $cursor)) {
55-
$tokens[] = stripcslashes(substr($match[0], 1, \strlen($match[0]) - 2));
55+
$tokens[] = stripcslashes(substr($match[0], 1, -1));
5656
} elseif (preg_match('/'.self::REGEX_STRING.'/A', $input, $match, 0, $cursor)) {
5757
$tokens[] = stripcslashes($match[1]);
5858
} else {

src/Symfony/Component/Mime/Header/AbstractHeader.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,14 +164,14 @@ protected function getEncodableWordTokens(string $string): array
164164
if ($this->tokenNeedsEncoding($token)) {
165165
$encodedToken .= $token;
166166
} else {
167-
if (\strlen($encodedToken) > 0) {
167+
if ('' !== $encodedToken) {
168168
$tokens[] = $encodedToken;
169169
$encodedToken = '';
170170
}
171171
$tokens[] = $token;
172172
}
173173
}
174-
if (\strlen($encodedToken)) {
174+
if ('' !== $encodedToken) {
175175
$tokens[] = $encodedToken;
176176
}
177177

src/Symfony/Component/Validator/Mapping/Loader/XmlFileLoader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ protected function parseConstraints(\SimpleXMLElement $nodes)
8585
} else {
8686
$options = [];
8787
}
88-
} elseif (\strlen((string) $node) > 0) {
88+
} elseif ('' !== (string) $node) {
8989
$options = XmlUtils::phpize(trim($node));
9090
} else {
9191
$options = null;

0 commit comments

Comments
 (0)
0