473,473 Members | 1,825 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

string class - memory reallocation

Hi All,

Does somebody know how to work with this class directly? I know that we
could redefine some internal predefined variables in C++ to force some
methods to run much faster. For example. If you use "string sOldString +=
sNewString;" in a loop the string class has to reallocate the memory each
time to insert the summarized string inside the new block of memory, then
copies this original string and appends a new string. We could change in C++
this step to make it significantly more so that this string could change the
memory reallocation only ones and then we could append more strings without
memory reallocation at all just inserting our characters beginning from the
last position and having the reserve for this append. Can we use the same
trick in C# to increase the speed of the application working with very long
strings? What I see right now - is very long work with strings and as longer
the strings as more annoying is this work.

Regards,
Dmitri.
Nov 13 '05 #1
2 3698
From what I have learned System.Text.StringBuilder is the way to go when
maipulating strings.

/K

"Dmitri Shvetsov" <ds*******@cox.net> wrote in message
news:a6bPa.1210$_s.912@fed1read03...
Hi All,

Does somebody know how to work with this class directly? I know that we
could redefine some internal predefined variables in C++ to force some
methods to run much faster. For example. If you use "string sOldString +=
sNewString;" in a loop the string class has to reallocate the memory each
time to insert the summarized string inside the new block of memory, then
copies this original string and appends a new string. We could change in C++ this step to make it significantly more so that this string could change the memory reallocation only ones and then we could append more strings without memory reallocation at all just inserting our characters beginning from the last position and having the reserve for this append. Can we use the same
trick in C# to increase the speed of the application working with very long strings? What I see right now - is very long work with strings and as longer the strings as more annoying is this work.

Regards,
Dmitri.

Nov 13 '05 #2
No, but StringBuilder is there for the kind of purposes you want.

S.

"Dmitri Shvetsov" <ds*******@cox.net> wrote in message
news:a6bPa.1210$_s.912@fed1read03...
Hi All,

Does somebody know how to work with this class directly? I know that we
could redefine some internal predefined variables in C++ to force some
methods to run much faster. For example. If you use "string sOldString +=
sNewString;" in a loop the string class has to reallocate the memory each
time to insert the summarized string inside the new block of memory, then
copies this original string and appends a new string. We could change in C++ this step to make it significantly more so that this string could change the memory reallocation only ones and then we could append more strings without memory reallocation at all just inserting our characters beginning from the last position and having the reserve for this append. Can we use the same
trick in C# to increase the speed of the application working with very long strings? What I see right now - is very long work with strings and as longer the strings as more annoying is this work.

Regards,
Dmitri.

Nov 13 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

66
by: Mike Stenzler | last post by:
I am new to Template programming and I would like to create an array of user-defined class objects using MFC CArray. Normally I would use linked list processing - create an object class and then an...
2
by: steflhermitte | last post by:
Dear cpp-ians, I have two structures: struct metaSegment { vector <long double> mean; bool full; };
26
by: Peter Mount | last post by:
Hello What's the syntax for using fgets() to store a string in memory? I understand that fgets() can solve the problem of storing a string that has more characters than the size of the declared...
5
by: fatted | last post by:
I'm trying to write a function which splits a string (possibly multiple times) on a particular character and returns the strings which has been split. What I have below is kind of (oh dear!)...
6
by: dough | last post by:
Heres a snippet of my code. I am trying to dynamically allocate memory for reading in strings from a file. FILE *f; /* file to read */ char *s; ...
74
by: ballpointpenthief | last post by:
If I have malloc()'ed a pointer and want to read from it as if it were an array, I need to know that I won't be reading past the last index. If this is a pointer to a pointer, a common technique...
81
by: Peter Olcott | last post by:
It looks like System::Collections::Generic.List throws and OUT_OF_MEMORY exception whenever memory allocated exceeds 256 MB. I have 1024 MB on my system so I am not even out of physical RAM, much...
1
by: sreenadh494 | last post by:
how we are reallocation memory in c++, is there any functions or automatically reallocated
15
by: Juha Nieminen | last post by:
I'm sure this is not a new idea, but I have never heard about it before. I'm wondering if this could work: Assume that you have a common base class and a bunch of classes derived from it, and...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.