logo       

RE: Clean way to do string.join: msg#00204

org.user-groups.dotnet.padnug

Subject: RE: Clean way to do string.join


Hmmm, yes, interesting point. But I'm not positive which would be optimal.

Granted the format string needs to be parsed, but there is a specific
overload for StringBuilder.AppendFormat( string format, object arg0, object
arg1 ) which might be optimized. OTOH, calling Append twice is more overhead
in making two calls. Or does the actual appending of strings in
StringBuilder dominate the performance?

It's going to be hard to tell without profiling and measuring actual
performance, assuming it became important. And I am not sure that I'd expect
the same results for the .NET Framework and the Compact Framework - they
could be implemented entirely differently.

Sounds like a great interview question!

Cheers,
Stuart

Stuart Celarier | Fern Creek | www.ferncrk.com

-----Original Message-----
From: John Theisen [mailto:jtheisenpdx@xxxxxxxxx]
Sent: Wednesday, January 26, 2005 11:08 AM
To: padnug@xxxxxxxxxxxxxxx
Subject: RE: [padnug] Clean way to do string.join


Stuart,
I think that the line

sb.AppendFormat ( "{0}{1}", separator, value[i] )

should be rewritten as

sb.Append(separator).Append(value[i]);

in the spirit of optimization.

-- John Theisen
jtheisenpdx@xxxxxxxxx








<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise