Relaxing the definition of isSomeString and isNarrowString

Andrei Alexandrescu via Digitalmars-d digitalmars-d at puremagic.com
Mon Aug 25 14:11:51 PDT 2014


On 8/25/14, 1:21 PM, monarch_dodra wrote:
> On Sunday, 24 August 2014 at 12:24:03 UTC, Andrei Alexandrescu wrote:
>> Look e.g. at
>> https://github.com/D-Programming-Language/phobos/blob/master/std/utf.d#L1074.
>> That's a memory allocation each and every time decodeImpl is called.
>> I'm not kidding. Take a look at http://goo.gl/p5pl3D vs.
>> http://goo.gl/YL2iFN. It's egregious.
>
> Dmitry already replied, but I want to stress the reply. That's complete
> BS. decodeImpl does *not* allocate. That line of code has been commented
> on, tested and benched. The enum is only ever used for CT indexing,
> which will *not* allocate.
>
> I'm repeatedly seeing people complain that decoding is slow. Maybe. And
> that it "allocates". But that's BS. A lot of people have been repeating
> this false information now, and I find it worrysome that both you and
> Walter have made this claim now.

That escalated quickly. Chillax.

The use of that enum array is fine but somewhat fragile - a small 
refactoring may trigger an allocation. Trying a static immutable array 
may be in order.

The larger point is there's significant optimization work that can be 
done on decoding before looking at other changes.


Andrei



More information about the Digitalmars-d mailing list