[M3devel] Text structure bites again...

Rodney M. Bates rodney.bates at wichita.edu
Sun Mar 30 21:05:16 CEST 2008


Just some thoughts:

Are all the intermediate TEXT values during all the concatenations
unused (other than for the next concatenation) until the whole
string is built, and only then get_chars?  If so, a possible
workaround might be to use a TextWr.T to build the string, then
TextWr.ToText.  It will keep a more efficient internal representation,
(expandable array of pointers to mutable buffers of almost 1000 chars
each,) and ToText is iterative.

Even if some of the intermediate strings are needed, but not too
often, it might be possible to do a TextWr.ToText and Wr.Put
to put the result right back into the TextWr.T and get  started
building the next longer string.

If you like it better to fix the TEXT implementation rather than
change your application,  I can imagine a better version of TextCat's
override of get_chars that recurses on only one of the two
component strings and iterates on the other.  I think it could
iterate on either component, as long as that is done temporally
last.

It could recurse on the component that is not another TextCat.T,
if there is one, otherwise, recurse on the component that is shorter.
This would only be a guess at which one is shallower, but might have
a reasonable probability of being the right guess.

Dragiša Durić wrote:
> Imagine string made by 50,000 & operations.
> 
> After that, we have very unbalanced tree of TextCat.T's.
> 
> Imagine get_chars() invocation by unsuspecting code.
> 
> 10MB of default stack goes crash.

-- 
-------------------------------------------------------------
Rodney M. Bates, retired assistant professor
Dept. of Computer Science, Wichita State University
Wichita, KS 67260-0083
316-978-3922
rodney.bates at wichita.edu



More information about the M3devel mailing list