]> granicus.if.org Git - php/commit
New memcpy()-based wordwrap() implementation. The simple case
authorjim winstead <jimw@php.net>
Sat, 5 Jan 2002 20:46:43 +0000 (20:46 +0000)
committerjim winstead <jimw@php.net>
Sat, 5 Jan 2002 20:46:43 +0000 (20:46 +0000)
commitca15b22212d3ea30c931e4cb7f4e1be869ed36fc
tree625d05aa1b7484346d79a5b64070c8fed07a2313
parente56fb1639b9c5da4f4d6b6b7b9c99888bfdd045b
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.
ext/standard/string.c
ext/standard/tests/strings/wordwrap.phpt