Skip to content

Commit

Permalink
Cache factory creation
Browse files Browse the repository at this point in the history
  • Loading branch information
slusarz committed Apr 17, 2014
1 parent 97c2a27 commit 5cbc4ec
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion imp/lib/Contents.php
Expand Up @@ -1080,6 +1080,8 @@ public function isAttachment($mime_type)
*/
protected function _buildMessage($parts = null)
{
global $injector;

if (is_null($parts)) {
if ($this->_build) {
return;
Expand All @@ -1094,6 +1096,8 @@ protected function _buildMessage($parts = null)
$last_id = null;
$to_process = array();

$mv_factory = $injector->getInstance('IMP_Factory_MimeViewer');

foreach ($parts as $id) {
if (!is_null($last_id) &&
(strpos($id, $last_id) === 0)) {
Expand All @@ -1103,7 +1107,7 @@ protected function _buildMessage($parts = null)
$last_id = null;

$mime_part = $this->getMIMEPart($id, array('nocontents' => true));
$viewer = $GLOBALS['injector']->getInstance('IMP_Factory_MimeViewer')->create($mime_part, array('contents' => $this));
$viewer = $mv_factory->create($mime_part, array('contents' => $this));
if ($viewer->embeddedMimeParts()) {
$mime_part = $this->getMIMEPart($id);
$viewer->setMIMEPart($mime_part);
Expand Down

0 comments on commit 5cbc4ec

Please sign in to comment.