Merge pull request #5422 from JackStouffer/endsWith-decoding

Removed auto-decoding from the single needle version of endsWith
merged-on-behalf-of: Jack Stouffer <jack@jackstouffer.com>
This commit is contained in:
The Dlang Bot 2017-05-25 21:53:15 +02:00 committed by GitHub
commit bd80096e44

View file

@ -1105,9 +1105,24 @@ bool endsWith(alias pred = "a == b", R, E)(R doesThisEnd, E withThis)
if (isBidirectionalRange!R &&
is(typeof(binaryFun!pred(doesThisEnd.back, withThis)) : bool))
{
return doesThisEnd.empty
? false
: binaryFun!pred(doesThisEnd.back, withThis);
if (doesThisEnd.empty)
return false;
alias predFunc = binaryFun!pred;
// auto-decoding special case
static if (isNarrowString!R)
{
// specialize for ASCII as to not change previous behavior
if (withThis <= 0x7F)
return predFunc(doesThisEnd[$ - 1], withThis);
else
return predFunc(doesThisEnd.back, withThis);
}
else
{
return predFunc(doesThisEnd.back, withThis);
}
}
/// Ditto