Skip to content

Commit b52fc76

Browse files
committed
Avoiding using functions in for loop
1 parent 8b0faee commit b52fc76

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

Symfony/src/Codebender/CompilerBundle/Handler/PreprocessingHandler.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@ function empty_braces($code)
7272
$start = 0;
7373
$return_code = "";
7474
// Use the code as an array of characters
75-
for ($i = 0; $i < strlen($code); $i++)
75+
$length = strlen($code);
76+
for ($i = 0; $i < $length; $i++)
7677
{
7778

7879
if ($code[$i] == "{")
@@ -95,7 +96,7 @@ function empty_braces($code)
9596

9697
}
9798
}
98-
$return_code .= substr($code, $start, strlen($code) - $start);
99+
$return_code .= substr($code, $start, $length - $start);
99100

100101
return $return_code;
101102
}
@@ -238,7 +239,9 @@ function build_code($code, $function_prototypes, $position)
238239
$next_pos = 0;
239240
else
240241
$next_pos = $position + 1;
241-
for ($i = $next_pos; $i < strlen($code); $i++)
242+
243+
$length = strlen($code);
244+
for ($i = $next_pos; $i < $length; $i++)
242245
{
243246
$return_code .= $code[$i];
244247
}

0 commit comments

Comments
 (0)