String Prefix Predicate
monarch_dodra via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sat Aug 16 13:59:46 PDT 2014
On Thursday, 14 August 2014 at 17:41:08 UTC, Nordlöw wrote:
> On Thursday, 14 August 2014 at 17:33:41 UTC, Justin Whear wrote:
>> std.algorithm.startsWith? Should auto-decode, so it'll do a
>
> What about
> https://github.com/D-Programming-Language/phobos/pull/2043
>
> Auto-decoding should be avoided when possible.
>
> I guess something like
>
> whole.byDchar().startsWith(part.byDchar())
>
> is preferred right?
I don't get it? If you use "byDchar", you are *explicitly*
decoding. How is that any better? If anything, you are
*preventing* the (many) opportunities phobos has to *avoid*
decoding when it can...
If you really want to avoid decoding, use either "representation"
which will do char[] => ubyte[] conversion, or "byCodeUnit",
which will create a range that returns single elements (IMO,
"byCodeUnit" should be prefered over "byChar", as it infers the
correct width).
More information about the Digitalmars-d-learn
mailing list