Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Avoid function usage in loops #5833

Merged
merged 1 commit into from

4 participants

@neeckeloo

Complete the previous pull request #5815.

@samsonasik

I think it doesn't make sense, see http://3v4l.org/Iu9gv#v500 and PR that I've created before #4923 that closed :p

@neeckeloo

I'm not sure that we speak exactly the same thing. Currently, in these cases, the number of items is calculated in each iteration. This could simply be done once before the execution of the loop and therefore improve performance.

@samsonasik

ok ;)

@bakura10

+1, can be merged!

@Maks3w Maks3w was assigned
@Maks3w Maks3w merged commit c62fdae into zendframework:master
@neeckeloo neeckeloo deleted the neeckeloo:avoid-functions-in-loops branch
@gianarb gianarb referenced this pull request from a commit in zendframework/zend-ldap
@Maks3w Maks3w Merge pull request zendframework/zf2#5833 dcb7dfd
@gianarb gianarb referenced this pull request from a commit in zendframework/zend-ldap
@Maks3w Maks3w Merge pull request zendframework/zf2#5833 in develop f327178
@gianarb gianarb referenced this pull request from a commit in zendframework/zend-ldap
@Maks3w Maks3w Merge pull request zendframework/zf2#5833 in master b1139ea
@gianarb gianarb referenced this pull request from a commit in zendframework/zend-mime
@Maks3w Maks3w Merge pull request zendframework/zf2#5833 61a991c
@gianarb gianarb referenced this pull request from a commit in zendframework/zend-mime
@Maks3w Maks3w Merge pull request zendframework/zf2#5833 in develop a952daa
@gianarb gianarb referenced this pull request from a commit in zendframework/zend-mime
@Maks3w Maks3w Merge pull request zendframework/zf2#5833 in master 6d333fa
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 16, 2014
  1. @neeckeloo
This page is out of date. Refresh to see the latest.
View
2  library/Zend/Ldap/Attribute.php
@@ -335,7 +335,7 @@ public static function getDateTimeAttribute(array $data, $attribName, $index = n
{
$values = static::getAttribute($data, $attribName, $index);
if (is_array($values)) {
- for ($i = 0; $i < count($values); $i++) {
+ for ($i = 0, $count = count($values); $i < $count; $i++) {
$newVal = static::valueFromLdapDateTime($values[$i]);
if ($newVal !== null) {
$values[$i] = $newVal;
View
2  library/Zend/Ldap/Filter/MaskFilter.php
@@ -24,7 +24,7 @@ public function __construct($mask, $value)
{
$args = func_get_args();
array_shift($args);
- for ($i = 0; $i < count($args); $i++) {
+ for ($i = 0, $count = count($args); $i < $count; $i++) {
$args[$i] = static::escapeValue($args[$i]);
}
$filter = vsprintf($mask, $args);
View
6 library/Zend/Mime/Mime.php
@@ -55,7 +55,7 @@ class Mime
"\xEF","\xF0","\xF1","\xF2","\xF3","\xF4","\xF5","\xF6",
"\xF7","\xF8","\xF9","\xFA","\xFB","\xFC","\xFD","\xFE",
"\xFF"
- );
+ );
public static $qpReplaceValues = array(
"=00","=01","=02","=03","=04","=05","=06","=07",
@@ -79,7 +79,7 @@ class Mime
"=EF","=F0","=F1","=F2","=F3","=F4","=F5","=F6",
"=F7","=F8","=F9","=FA","=FB","=FC","=FD","=FE",
"=FF"
- );
+ );
public static $qpKeysString =
"\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F\x7F\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8A\x8B\x8C\x8D\x8E\x8F\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9A\x9B\x9C\x9D\x9E\x9F\xA0\xA1\xA2\xA3\xA4\xA5\xA6\xA7\xA8\xA9\xAA\xAB\xAC\xAD\xAE\xAF\xB0\xB1\xB2\xB3\xB4\xB5\xB6\xB7\xB8\xB9\xBA\xBB\xBC\xBD\xBE\xBF\xC0\xC1\xC2\xC3\xC4\xC5\xC6\xC7\xC8\xC9\xCA\xCB\xCC\xCD\xCE\xCF\xD0\xD1\xD2\xD3\xD4\xD5\xD6\xD7\xD8\xD9\xDA\xDB\xDC\xDD\xDE\xDF\xE0\xE1\xE2\xE3\xE4\xE5\xE6\xE7\xE8\xE9\xEA\xEB\xEC\xED\xEE\xEF\xF0\xF1\xF2\xF3\xF4\xF5\xF6\xF7\xF8\xF9\xFA\xFB\xFC\xFD\xFE\xFF";
@@ -208,7 +208,7 @@ public static function encodeQuotedPrintableHeader($str, $charset,
}
// assemble the lines together by pre- and appending delimiters, charset, encoding.
- for ($i = 0; $i < count($lines); $i++) {
+ for ($i = 0, $count = count($lines); $i < $count; $i++) {
$lines[$i] = " " . $prefix . $lines[$i] . "?=";
}
$str = trim(implode($lineEnd, $lines));
Something went wrong with that request. Please try again.