List of Phobos functions that allocate memory?

Timon Gehr timon.gehr at gmx.ch
Sat Feb 8 11:02:05 PST 2014


On 02/08/2014 07:44 PM, Brad Anderson wrote:
> On Saturday, 8 February 2014 at 05:04:35 UTC, Jonathan M Davis
> wrote:
>> I think that that would call for us to have 3 related but distinct
>> functions:
>>
>> 1. decode, which throws on invalid Unicode. We already have this.
>
> I wonder if it'd be too reckless to just make decode for string
> nothrow (we want this function to be as fast as possible) and
> just require that string, by definition, must be valid unicode.
> to!string and company could validate strings as they come in from
> foreign sources. This way invalid unicode is caught early and
> decode gets a speedup.
>
> char[] is different because the mutability means it could be made
> invalid at any time so we can't rely on it staying valid after
> it's been checked but once a string has been confirmed valid
> there is no reason to check it for validity ever again.

"☹"[1..$]


More information about the Digitalmars-d mailing list