Re: cvs: php4 /ext/standard string.c /ext/standard/tests/strings wordwrap.phpt
| From: | Andi Gutmans | Date: | Sat, 05 Jan 2002 21:02:51 +0000 |
| Subject: | Re: cvs: php4 /ext/standard string.c /ext/standard/tests/strings wordwrap.phpt | ||
| References: | 1 | Groups: | php.cvs |
| Request: | Send a blank email to php-cvs+get-8957@lists.php.net to get a copy of this message | ||
Nice!
At 08:46 PM 1/5/2002 +0000, jim winstead wrote:
jimw Sat Jan 5 15:46:45 2002 EDTModified files:/php4/ext/standard string.c /php4/ext/standard/tests/strings wordwrap.phptLog: New memcpy()-based wordwrap() implementation. The simple case (single-character break, no forced break) appears to be about 60% faster, and there's simply no comparison for non-simple cases with non-trivial amounts of text. The old algorithm was O(n^2) (with an unfortunately large constant factor) because of the use of strncat(), the new one is O(n). Added some more tests, too. @ - Made wordwrap() significantly faster. (Jim) # test case: $t = join('',file('ChangeLog')); $w = wordwrap($t,10,"\n",1); # new code completes in less than a second. i'm still waiting for the # old code to finish.