Using replaceInPlace, string and char[]

Ali Çehreli via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Aug 15 07:33:44 PDT 2015


On 08/15/2015 01:47 AM, TSalm wrote:

 > Must create a ticket for it ?

I think so. Unless others object in 10 minutes... :)

 > In the other hand using "string" is not
 > efficient since this certainly make a copy of the original string. 
Right ?
 > This is better to use "replaceInPlace" with "char[]", but this doesn't
 > actually work :-(

There is probably a workaround, which others will hopefully show. (I 
have to leave now. :) ) However, although not in your example, 
replaceInPlace would still copy if the result would not fit in the 
original char[]. Hm... Come to think of it, it cannot replace in place 
anyway, unless it knows that the slice is the only one looking at those 
characters. Otherwise, you would disturbing your other slices. (?)

Ali



More information about the Digitalmars-d-learn mailing list