Thanks Steven, that was very informative!
"Steven Schveighoffer" wrote in message
news:op.vwzrwdmteav7ka@localhost.localdomain...
On Sun, 12 Jun 2011 21:02:05 -0400, Lloyd Dupont
wrote:
But... string being immutable I don't see the point of allocating some
space for one..
Am I missing som
On Sun, 12 Jun 2011 21:02:05 -0400, Lloyd Dupont
wrote:
But... string being immutable I don't see the point of allocating some
space for one..
Am I missing something?
Reserving space for appending does not make that space immutable, yet.
As far as the runtime is concerned, that space is
On 2011-06-12 18:02, Lloyd Dupont wrote:
> But... string being immutable I don't see the point of allocating some
> space for one..
> Am I missing something?
Just because it's immutable doesn't mean that it doesn't need to exist at
runtime. All immutable means is that you can't change it. It coul
Thanks!
"Jonathan M Davis" wrote in message
news:mailman.851.1307909610.14074.digitalmars-d-
Also, std.string.repeat has been scheduled for deprecation. You should use
std.array.replicate instead. It does the same thing but for all arrays
instead
of just strings.
- Jonathan M Davis
But... string being immutable I don't see the point of allocating some space
for one..
Am I missing something?
"Steven Schveighoffer" wrote in message
news:op.vwy503w4eav7ka@localhost.localdomain...
On Sun, 12 Jun 2011 12:49:25 -0400, Lloyd Dupont
wrote:
I have a method like that:
===
pub
On 2011-06-12 11:08, Steven Schveighoffer wrote:
> On Sun, 12 Jun 2011 12:49:25 -0400, Lloyd Dupont
>
> wrote:
> > I have a method like that:
> > ===
> > public string repeat(string s, int num)
> > {
> >
> > string result = s;
> > for (int i=1; i >
> > result ~= s;
> >
On Sun, 12 Jun 2011 12:49:25 -0400, Lloyd Dupont
wrote:
I have a method like that:
===
public string repeat(string s, int num)
{
string result = s;
for (int i=1; i
The runtime tries its best to avoid allocating a new string on each
append. Please read the manual on appending, and
I have a method like that:
===
public string repeat(string s, int num)
{
string result = s;
for (int i=1; i