[m-rev.] diff: implement concat_string_list for .NET

Zoltan Somogyi zs at cs.mu.OZ.AU
Mon Feb 17 18:04:03 AEDT 2003


On 17-Feb-2003, Michael Day <mikeday at yeslogic.com> wrote:
> Are there any studies comparing the efficiency of the two string
> approaches?

Yes, but they can't be used to say that one representation is better overall.
Some operations are better if you explicitly record the length; e.g.
string__append_list can be implemented without duplicate traversal of any
string *and* without wasting memory. Most other operations are better with
null-terminated strings, since you avoid the small overhead of maintaining
the length. In any case, with today's machines, efficiency is simply not an
issue, except for strings that are long enough for something like cords
to be better than both primitive representations in any case.

In practice, taste and interface convenience are far more important than
performance. Even a purported strength such as the ability of counted strings
to contain any character, including null, can turn into a weakness, if you
have to interface to other systems (e.g. the operating system) that require
null-terminated strings. (In that case, you may have to scan a string with an
explicit length to search for nulls before the end of the string, and even
if that scan is negative, you may have to copy the string to buffer that has
room for the final null to be inserted.)

Zoltan.
--------------------------------------------------------------------------
mercury-reviews mailing list
post:  mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the reviews mailing list