Skip to content

Commit

Permalink
Revert "[!]: update for performance (need some testing) v2"
Browse files Browse the repository at this point in the history
This reverts commit e1df8bc.
  • Loading branch information
Lars Moelleken committed Dec 10, 2015
1 parent fd07366 commit 9372e3f
Show file tree
Hide file tree
Showing 11 changed files with 33 additions and 59 deletions.
1 change: 0 additions & 1 deletion lib/classes/Swift.php
Expand Up @@ -19,7 +19,6 @@ abstract class Swift
const VERSION = '5.x';

public static $initialized = false;
public static $useMemorySpool = false;
public static $inits = array();

/**
Expand Down
4 changes: 1 addition & 3 deletions lib/classes/Swift/Encoder/QpEncoder.php
Expand Up @@ -301,8 +301,6 @@ protected function _standardize($string)
*/
public function __clone()
{
if (true === Swift::$useMemorySpool) {
$this->_charStream = clone $this->_charStream;
}
$this->_charStream = clone $this->_charStream;
}
}
4 changes: 1 addition & 3 deletions lib/classes/Swift/Encoder/Rfc2231Encoder.php
Expand Up @@ -90,8 +90,6 @@ public function charsetChanged($charset)
*/
public function __clone()
{
if (true === Swift::$useMemorySpool) {
$this->_charStream = clone $this->_charStream;
}
$this->_charStream = clone $this->_charStream;
}
}
2 changes: 0 additions & 2 deletions lib/classes/Swift/KeyCache/ArrayKeyCache.php
Expand Up @@ -120,11 +120,9 @@ public function importFromByteStream($nsKey, $itemKey, Swift_OutputByteStream $o
public function getInputByteStream($nsKey, $itemKey, Swift_InputByteStream $writeThrough = null)
{
$is = clone $this->_stream;

$is->setKeyCache($this);
$is->setNsKey($nsKey);
$is->setItemKey($itemKey);

if (isset($writeThrough)) {
$is->setWriteThroughStream($writeThrough);
}
Expand Down
8 changes: 1 addition & 7 deletions lib/classes/Swift/MemorySpool.php
Expand Up @@ -17,12 +17,6 @@ class Swift_MemorySpool implements Swift_Spool
{
protected $messages = array();

public function __construct()
{
Swift::$useMemorySpool = true;
}


/**
* Tests if this Transport mechanism has started.
*
Expand Down Expand Up @@ -56,7 +50,7 @@ public function stop()
*/
public function queueMessage(Swift_Mime_Message $message)
{
// clone the message to make sure it is not changed while in the queue
//clone the message to make sure it is not changed while in the queue
$this->messages[] = clone $message;

return true;
Expand Down
14 changes: 6 additions & 8 deletions lib/classes/Swift/Message.php
Expand Up @@ -287,16 +287,14 @@ protected function restoreMessage()
*/
public function __clone()
{
if (true === Swift::$useMemorySpool) {
parent::__clone();
parent::__clone();

foreach ($this->bodySigners as $key => $bodySigner) {
$this->bodySigners[$key] = clone($bodySigner);
}
foreach ($this->bodySigners as $key => $bodySigner) {
$this->bodySigners[$key] = clone($bodySigner);
}

foreach ($this->headerSigners as $key => $headerSigner) {
$this->headerSigners[$key] = clone($headerSigner);
}
foreach ($this->headerSigners as $key => $headerSigner) {
$this->headerSigners[$key] = clone($headerSigner);
}
}
}
Expand Up @@ -51,10 +51,8 @@ public function __construct(Swift_Mime_ContentEncoder_QpContentEncoder $safeEnco
*/
public function __clone()
{
if (true === Swift::$useMemorySpool) {
$this->safeEncoder = clone $this->safeEncoder;
$this->nativeEncoder = clone $this->nativeEncoder;
}
$this->safeEncoder = clone $this->safeEncoder;
$this->nativeEncoder = clone $this->nativeEncoder;
}

/**
Expand Down
6 changes: 2 additions & 4 deletions lib/classes/Swift/Mime/SimpleHeaderFactory.php
Expand Up @@ -197,10 +197,8 @@ public function charsetChanged($charset)
*/
public function __clone()
{
if (true === Swift::$useMemorySpool) {
$this->_encoder = clone $this->_encoder;
$this->_paramEncoder = clone $this->_paramEncoder;
}
$this->_encoder = clone $this->_encoder;
$this->_paramEncoder = clone $this->_paramEncoder;
}

/**
Expand Down
10 changes: 4 additions & 6 deletions lib/classes/Swift/Mime/SimpleHeaderSet.php
Expand Up @@ -446,13 +446,11 @@ private function _notifyHeadersOfCharset($charset)
*/
public function __clone()
{
if (true === Swift::$useMemorySpool) {
$this->_factory = clone $this->_factory;
$this->_factory = clone $this->_factory;

foreach ($this->_headers as $groupKey => $headerGroup) {
foreach ($headerGroup as $key => $header) {
$this->_headers[$groupKey][$key] = clone $header;
}
foreach ($this->_headers as $groupKey => $headerGroup) {
foreach ($headerGroup as $key => $header) {
$this->_headers[$groupKey][$key] = clone $header;
}
}
}
Expand Down
34 changes: 14 additions & 20 deletions lib/classes/Swift/Mime/SimpleMimeEntity.php
Expand Up @@ -957,27 +957,21 @@ private function _assertValidId($id)
*/
public function __clone()
{
if (true === Swift::$useMemorySpool) {
$this->_headers = clone $this->_headers;
$this->_encoder = clone $this->_encoder;

// TODO? do we need this ? -> https://github.com/bmurashin/swiftmailer/commit/ef5c5134e6e02afc2e8ff3287bfa74be1b33dcaf
//$this->_cacheKey = $this->_generateNewCacheKey();
//$this->generateId();

$children = array();
foreach ($this->_children as $pos => $child) {
if (
$child instanceof Swift_Mime_Attachment
||
$child instanceof Swift_Mime_EmbeddedFile
) {
$children[$pos] = $child;
} else {
$children[$pos] = clone $child;
}
$this->_headers = clone $this->_headers;
$this->_encoder = clone $this->_encoder;

// TODO? do we need this ? -> https://github.com/bmurashin/swiftmailer/commit/ef5c5134e6e02afc2e8ff3287bfa74be1b33dcaf
//$this->_cacheKey = $this->_generateNewCacheKey();
//$this->generateId();

$children = array();
foreach ($this->_children as $pos => $child) {
if ($child instanceof Swift_Mime_Attachment || $child instanceof Swift_Mime_EmbeddedFile) {
$children[$pos] = $child;
} else {
$children[$pos] = clone $child;
}
$this->setChildren($children);
}
$this->setChildren($children);
}
}
3 changes: 2 additions & 1 deletion lib/classes/Swift/SpoolTransport.php
Expand Up @@ -22,7 +22,8 @@ class Swift_SpoolTransport extends Swift_Transport_SpoolTransport
*/
public function __construct(Swift_Spool $spool)
{
$arguments = Swift_DependencyContainer::getInstance()->createDependenciesFor('transport.spool');
$arguments = Swift_DependencyContainer::getInstance()
->createDependenciesFor('transport.spool');

$arguments[] = $spool;

Expand Down

0 comments on commit 9372e3f

Please sign in to comment.