PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » Mail » Mail_Mime » Bug #1491

Boundary string generation too "expensive"

Details

Submitted2004-05-25 08:41 UTC
Frommk at peytz dot dk
Assignedsean
StatusClosed
PackageMail_Mime
PHP Version4.3.4
OSDebian GNU/Linux
Roadmaps(Not assigned)

Comments

[2004-05-25 08:41 UTC] mk at peytz dot dk

Description:
------------
Regarding Mail_Mime version 1.2.1 (stable)

When profiling (with PECL APD) code that uses Mail_Mime I found that a large amount of time was used calling uniqid from within the Mail_Mime constructor function.

It seems to me that simply skipping the call to uniqid will still generate enough entropy to the boundary string and at the same time reduce the time consumption;
$this->_boundary = '=_' . md5(time());
instead of
$this->_boundary = '=_' . md5(uniqid(time()));
in line 112 of Mail/mime.php

Best regards,
Michael Kyed

[2004-10-12 10:14 UTC] geels at datainlife dot ru

Moreover, this string, you found, is _useless_!
$this->_boundary never used anywhere.

Boundary generation code is in Mail/mimePart.php line 222:

$boundary = '=_' . md5(uniqid(rand()) . microtime());

this one is REAL execution time hog! I think, "md5(rand() . microtime())" would be enough (faster about 600 times!!).