[Issue 5059] String assignment in foreach loop breaks immutability
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue May 24 14:48:41 PDT 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5059
--- Comment #3 from Steven Schveighoffer <schveiguy at yahoo.com> 2011-05-24 14:44:26 PDT ---
I think the better solution is to change it to const(char)[]. This better
reflects that the data may be changing between iterations. If you are not
storing the strings from this, then it is extremely wasteful to allocate a new
memory block for each iteration. You can always idup or dup if you want to.
Note, I think the documentation needs to specifically state it reuses the
buffer, so you should .dup or .idup if you wish to keep the data beyond the
loop iteration.
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list