string performance

  • Thread starter Thread starter Servé Lau
  • Start date Start date
S

Servé Lau

I have an application which is very string intensive, therefore I'm
wondering about the string performance.

suppose I use this construct

string getString()
{
....processing
return s;
}

Will this create a new string like it would in java or is it reference
counted?
Am I better off with storing a member veriable and do the processing there?

I'm sorry that I have to ask here. No time to test this myself and maybe
somebody else will learn from it.
 
You can do that just fine. If you use strings like this make sure you use a
StringBuilder to build your string. The string returned is valid as long as
a variable has a reference to it. After that the garbage collector will
clear it out.

+++ Rick ---

--

Rick Strahl
West Wind Technologies
http://www.west-wind.com/
http://www.west-wind.com/wwHelp
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top