On Mon, 12 Dec 2011 12:59:11 -0500, Timon Gehr <timon.g...@gmx.ch> wrote:
On 12/12/2011 06:37 PM, bearophile wrote:
Timon Gehr:
string fragString = readText( "Shader.vert" ) ~ '\0';
I think using toStringz is more self-documenting.
Bye,
bearophile
There is nothing more self-documenting than actually appending the zero.
Claiming toStringz is better in that regard is like saying a+1 is less
self-documenting than doAddo(a) ;)
There might be other benefits of using toStringz though, (for example,
it won't add the zero if it is already there, but that does not apply
here).
x ~ y *always* makes a copy of x, whereas toStringz(x) will (should?) use
append (which could potentially save another heap allocation). However,
I'm not sure what kind of state the result of readText is in.
-Steve