Skip to content

Commit

Permalink
Avoiding using functions in for loop
Browse files Browse the repository at this point in the history
  • Loading branch information
tzikis committed Jan 9, 2015
1 parent 8b0faee commit b52fc76
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ function empty_braces($code)
$start = 0;
$return_code = "";
// Use the code as an array of characters
for ($i = 0; $i < strlen($code); $i++)
$length = strlen($code);
for ($i = 0; $i < $length; $i++)
{

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

}
}
$return_code .= substr($code, $start, strlen($code) - $start);
$return_code .= substr($code, $start, $length - $start);

return $return_code;
}
Expand Down Expand Up @@ -238,7 +239,9 @@ function build_code($code, $function_prototypes, $position)
$next_pos = 0;
else
$next_pos = $position + 1;
for ($i = $next_pos; $i < strlen($code); $i++)

$length = strlen($code);
for ($i = $next_pos; $i < $length; $i++)
{
$return_code .= $code[$i];
}
Expand Down

0 comments on commit b52fc76

Please sign in to comment.