Major performance problem with std.array.front()

H. S. Teoh hsteoh at quickfur.ath.cx
Thu Mar 6 19:31:17 PST 2014


On Thu, Mar 06, 2014 at 06:59:36PM -0800, Walter Bright wrote:
> On 3/6/2014 6:54 PM, bearophile wrote:
> >Walter Bright:
> >>Is there any hope of fixing this?
> >
> >I don't think we can change that in D2. You can change it in D3.
> 
> You use ranges a lot. Would it break any of your code?

Whoa. You're not serious about changing this now, are you? Because even
though I would support such a change, you have to realize the magnitude
of code breakage that will happen. A lot of code that iterates over
narrow strings will break, and worse yet, they will break *silently*.
Calling count() on a narrow string will not return the expected value,
for example. And existing code that iterates over narrow strings
expecting dchars to come out of it will suddenly silently convert to
char, and may pass by unnoticed until somebody runs the program with a
multibyte character in the input.

This is very high risk change IMO.

You're welcome to create a (temporary) Phobos fork that reverts narrow
string auto-decoding, of course, and people can try it out to see how
much actual breakage is happening. If you really want to push for this,
that might be the safest way to test the waters before committing to
such a major change. Silent breakage is not easy to test for,
unfortunately. :(


T

-- 
Truth, Sir, is a cow which will give [skeptics] no more milk, and so
they are gone to milk the bull. -- Sam. Johnson


More information about the Digitalmars-d mailing list