Changeset 7673 for trunk/library/mime


Ignore:
Timestamp:
12/18/12 16:15:29 (11 years ago)
Author:
douglasz
Message:

Ticket #3236 - Correcoes para Performance: Function Within Loop Declaration.

Location:
trunk/library/mime
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/library/mime/mime.php

    r7655 r7673  
    895895        case !$text && !$html && $attachments: 
    896896            $message =& $this->_addMixedPart(); 
    897             for ($i = 0; $i < count($this->_parts); ++$i) { 
     897            $parts_count = count($this->_parts); 
     898            for ($i = 0; $i < $parts_count; ++$i) { 
    898899                $this->_addAttachmentPart($message, $this->_parts[$i]); 
    899900            } 
     
    903904            $message =& $this->_addMixedPart(); 
    904905            $this->_addTextPart($message, $this->_txtbody); 
    905             for ($i = 0; $i < count($this->_parts); ++$i) { 
     906            $parts_count = count($this->_parts); 
     907            for ($i = 0; $i < $parts_count; ++$i) { 
    906908                $this->_addAttachmentPart($message, $this->_parts[$i]); 
    907909            } 
     
    930932                $ht =& $this->_addRelatedPart($message); 
    931933                $this->_addHtmlPart($ht); 
    932                 for ($i = 0; $i < count($this->_html_images); ++$i) { 
     934                $html_images_count = count($this->_html_images); 
     935                for ($i = 0; $i < $html_images_count; ++$i) { 
    933936                    $this->_addHtmlImagePart($ht, $this->_html_images[$i]); 
    934937                } 
     
    939942                $message =& $this->_addRelatedPart($null); 
    940943                $this->_addHtmlPart($message); 
    941                 for ($i = 0; $i < count($this->_html_images); ++$i) { 
     944                $html_images_count = count($this->_html_images); 
     945                for ($i = 0; $i < $html_images_count; ++$i) { 
    942946                    $this->_addHtmlImagePart($message, $this->_html_images[$i]); 
    943947                } 
     
    958962                $this->_addHtmlPart($message); 
    959963            } 
    960             for ($i = 0; $i < count($this->_html_images); ++$i) { 
     964            $html_images_count = count($this->_html_images); 
     965            for ($i = 0; $i < $html_images_count; ++$i) { 
    961966                $this->_addHtmlImagePart($message, $this->_html_images[$i]); 
    962967            } 
     
    973978                $this->_addHtmlPart($message); 
    974979            } 
    975             for ($i = 0; $i < count($this->_parts); ++$i) { 
     980            $parts_count = count($this->_parts); 
     981            for ($i = 0; $i < $parts_count; ++$i) { 
    976982                $this->_addAttachmentPart($message, $this->_parts[$i]); 
    977983            } 
     
    989995            } 
    990996            $this->_addHtmlPart($rel); 
    991             for ($i = 0; $i < count($this->_html_images); ++$i) { 
     997                    $html_images_count = count($this->_html_images); 
     998            for ($i = 0; $i < $html_images_count; ++$i) { 
    992999                $this->_addHtmlImagePart($rel, $this->_html_images[$i]); 
    9931000            } 
    994             for ($i = 0; $i < count($this->_parts); ++$i) { 
     1001                    $parts_count = count($this->_parts); 
     1002            for ($i = 0; $i < $parts_count; ++$i) { 
    9951003                $this->_addAttachmentPart($message, $this->_parts[$i]); 
    9961004            } 
     
    10081016                                $this->_addHtmlPart($message); 
    10091017            } 
    1010                          
    1011             for ($i = 0; $i < count($this->_html_images); ++$i) { 
     1018 
     1019                        $html_images_count = count($this->_html_images); 
     1020            for ($i = 0; $i < $html_images_count; ++$i) { 
    10121021                $this->_addHtmlImagePart($message, $this->_html_images[$i]); 
    10131022            } 
    1014             for ($i = 0; $i < count($this->_parts); ++$i) { 
     1023            $parts_count = count($this->_parts); 
     1024            for ($i = 0; $i < $parts_count; ++$i) { 
    10151025                $this->_addAttachmentPart($message, $this->_parts[$i]); 
    10161026            } 
  • trunk/library/mime/mimeDecode.php

    r7655 r7673  
    326326 
    327327                    $parts = $this->_boundarySplit($body, $content_type['other']['boundary']); 
    328                     for ($i = 0; $i < count($parts); ++$i) { 
     328                    $parts_count = count($parts); 
     329                    for ($i = 0; $i < $parts_count; ++$i) { 
    329330                        list($part_header, $part_body) = $this->_splitBodyHeader($parts[$i]); 
    330331                        $part = $this->_decode($part_header, $part_body, $default_ctype); 
     
    386387                $return[$prepend . $mime_number] = &$structure; 
    387388            } 
    388             for ($i = 0; $i < count($structure->parts); ++$i) { 
    389  
     389            $structure_parts_count = count($structure->parts); 
     390            for ($i = 0; $i < $structure_parts_count; ++$i) { 
    390391             
    391392                if (!empty($structure->headers['content-type']) AND substr(strtolower($structure->headers['content-type']), 0, 8) == 'message/') { 
     
    792793        preg_match_all("/begin ([0-7]{3}) (.+)\r?\n(.+)\r?\nend/Us", $input, $matches); 
    793794 
    794         for ($j = 0; $j < count($matches[3]); ++$j) { 
     795        $matches_count = count($matches[3]); 
     796        for ($j = 0; $j < $matches_count; ++$j) { 
    795797 
    796798            $str      = $matches[3][$j]; 
     
    943945            // Multiple headers with this name 
    944946            if (is_array($headers[$hdr_name])) { 
    945                 for ($i = 0; $i < count($hdr_value); ++$i) { 
     947                $hdr_value_count = count($hdr_value); 
     948                for ($i = 0; $i < $hdr_value_count; ++$i) { 
    946949                    $output .= Mail_mimeDecode::_getXML_helper($hdr_name, $hdr_value[$i], $indent); 
    947950                } 
     
    954957 
    955958        if (!empty($input->parts)) { 
    956             for ($i = 0; $i < count($input->parts); ++$i) { 
     959            $parts_count = count($input->parts); 
     960            for ($i = 0; $i < $parts_count; ++$i) { 
    957961                $output .= $crlf . str_repeat($htab, $indent) . '<mimepart>' . $crlf . 
    958962                           Mail_mimeDecode::_getXML($input->parts[$i], $indent+1) . 
  • trunk/library/mime/mimePart.php

    r7655 r7673  
    283283            $encoded['body'] = '';  
    284284 
    285             for ($i = 0; $i < count($this->_subparts); ++$i) { 
     285            $subparts_count = count($this->_subparts); 
     286            for ($i = 0; $i < $subparts_count; ++$i) { 
    286287                $encoded['body'] .= '--' . $boundary . $eol; 
    287288                $tmp = $this->_subparts[$i]->encode(); 
     
    393394 
    394395        if (count($this->_subparts)) { 
    395             for ($i = 0; $i < count($this->_subparts); ++$i) { 
     396            $subparts_count = count($this->_subparts); 
     397            for ($i = 0; $i < $subparts_count; ++$i) { 
    396398                fwrite($fh, $f_eol . '--' . $boundary . $eol); 
    397399                $res = $this->_subparts[$i]->_encodePartToFile($fh); 
Note: See TracChangeset for help on using the changeset viewer.