[m-dev.] Addition to string/performance bug fix

Fergus Henderson fjh at cs.mu.oz.au
Tue Jul 1 11:35:45 AEST 1997


Thomas Charles CONWAY, you wrote:
> Fix a performance bug which meant that it took about 3 cpu minutes for
> hydra to quote an 85K string in order to io__write it out. The bug was
> that string__first_char(in, out, out) has a cost of O(n^2) in the length
> of the string, and term_io__write_escaped_string called it successively
> to escape each character of the string. The fix was to add a predicate
> string__foldl which is equivalent to
> 	string__to_char_list(Str, Chars), list__foldl(Closure, Chars, Acc0, Acc)
> except that its implementation avoids the intermediate list.

s/n^2/n/

string__first_char is O(n), term_io__write_escaped_string is the
one that was O(n^2).

-- 
Fergus Henderson <fjh at cs.mu.oz.au>   |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>   |  of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3         |     -- the last words of T. S. Garp.



More information about the developers mailing list