Skip to content

Commit

Permalink
[mms] Optimizations to address parsing.
Browse files Browse the repository at this point in the history
  • Loading branch information
slusarz committed Feb 11, 2014
1 parent 976159d commit 3085182
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 15 deletions.
29 changes: 16 additions & 13 deletions framework/Mail/lib/Horde/Mail/Rfc822.php
Expand Up @@ -517,22 +517,22 @@ protected function _rfc822ParsePhrase(&$phrase)
throw new Horde_Mail_Exception('Error when parsing a group.');
}

while (($curr = $this->_curr()) !== false) {
do {
if ($curr == '"') {
$this->_rfc822ParseQuotedString($phrase);
} else {
$this->_rfc822ParseAtomOrDot($phrase);
}

$chr = $this->_curr();
if (($chr != '"') &&
($chr != '.') &&
!$this->_rfc822IsAtext($chr)) {
$curr = $this->_curr();
if (($curr != '"') &&
($curr != '.') &&
!$this->_rfc822IsAtext($curr)) {
break;
}

$phrase .= ' ';
}
} while ($this->_ptr < $this->_datalen);

$this->_rfc822SkipLwsp();
}
Expand Down Expand Up @@ -590,21 +590,21 @@ protected function _rfc822ParseQuotedString(&$str)
*/
protected function _rfc822ParseDotAtom(&$str, $validate = null)
{
$curr = $this->_curr();
if (($curr === false) || !$this->_rfc822IsAtext($curr, $validate)) {
throw new Horde_Mail_Exception('Error when parsing dot-atom.');
}

$is_validate = $this->_params['validate'];
$valid = false;

while ($this->_ptr < $this->_datalen) {
$chr = $this->_data[$this->_ptr];

while (($chr = $this->_curr()) !== false) {
/* $this->_rfc822IsAtext($chr, $validate);
* Optimization: Function would be called excessively in this
* loop, so eliminate function call overhead. */
if (($is_validate && !strcspn($chr, self::ATEXT)) ||
(!$is_validate && strcspn($chr, $validate))) {
$str .= $chr;
++$this->_ptr;
} elseif (!$valid) {
throw new Horde_Mail_Exception('Error when parsing dot-atom.');
} else {
$this->_rfc822SkipLwsp();

Expand All @@ -615,6 +615,8 @@ protected function _rfc822ParseDotAtom(&$str, $validate = null)

$this->_rfc822SkipLwsp(true);
}

$valid = true;
}
}

Expand All @@ -632,7 +634,8 @@ protected function _rfc822ParseAtomOrDot(&$str)
{
$validate = $this->_params['validate'];

while (($chr = $this->_curr()) !== false) {
while ($this->_ptr < $this->_datalen) {
$chr = $this->_data[$this->_ptr];
if (($chr != '.') &&
/* !$this->_rfc822IsAtext($chr, ',<:');
* Optimization: Function would be called excessively in this
Expand Down
4 changes: 2 additions & 2 deletions framework/Mail/package.xml
Expand Up @@ -21,7 +21,7 @@
</stability>
<license uri="http://www.horde.org/licenses/bsd">BSD-2-Clause</license>
<notes>
*
* [mms] Optimizations to address parsing.
</notes>
<contents>
<dir baseinstalldir="/" name="/">
Expand Down Expand Up @@ -562,7 +562,7 @@
<date>2014-02-11</date>
<license uri="http://www.horde.org/licenses/bsd">BSD-2-Clause</license>
<notes>
*
* [mms] Optimizations to address parsing.
</notes>
</release>
</changelog>
Expand Down

0 comments on commit 3085182

Please sign in to comment.