Challenge: write a really really small front() for UTF8

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Sun Mar 23 15:58:32 PDT 2014


On 3/23/14, 3:10 PM, Dmitry Olshansky wrote:
> 24-Mar-2014 01:34, Andrei Alexandrescu пишет:
>> On 3/23/14, 2:29 PM, Dmitry Olshansky wrote:
>>> 24-Mar-2014 01:22, Andrei Alexandrescu пишет:
>>>> Here's a baseline: http://goo.gl/91vIGc. Destroy!
>>>>
>>> Assertions to check encoding?!
>>> I thought it would detect broken encoding and do a substitution at
>>> least.
>>
>> That implementation does zero effort to optimize checks themselves, and
>> indeed puts them in asserts. I think there's value in having such a
>> primitive down below.
>
> Just how much you are willing to assert? You don't even check length.

Array bounds checking takes care of that.

> In short - what are the specs of this primitive and where you see it
> being used.

A replacement for front() in arrays of char and wchar.


Andrei



More information about the Digitalmars-d mailing list