Detecting at compile time if a string is zero terminated

Johannes Pfau spam at
Thu Jan 20 05:47:05 PST 2011

Jesse Phillips wrote:
>First off no. Second, is their really going to be a performance gain
>from this. I wouldn't expect static strings to be converted very
>often. And last I will copy and past a comment from the source code:

Thanks for your reply.
In case you don't know: gettext is used to translate strings.
You call gettext("english string") and it returns the translated
string. Gettext might be the only corner case, but the strings gettext
returns are usually not cached and big projects could translate many
strings, so I thought it could be an issue. But maybe I'm
overestimating that.
I had a look at the source code of toStringz and found the comment you
mentioned. The comment is for toStringz(const(char)[] s)
toStringz(string s) is even more interesting in this case as it does do
that optimization in most cases. I think that's good enough ;-)

Johannes Pfau
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <>

More information about the Digitalmars-d-learn mailing list