mirror of
https://github.com/dlang/phobos.git
synced 2025-04-29 22:50:38 +03:00
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:
commit
bd80096e44
1 changed files with 18 additions and 3 deletions
|
@ -1105,9 +1105,24 @@ bool endsWith(alias pred = "a == b", R, E)(R doesThisEnd, E withThis)
|
||||||
if (isBidirectionalRange!R &&
|
if (isBidirectionalRange!R &&
|
||||||
is(typeof(binaryFun!pred(doesThisEnd.back, withThis)) : bool))
|
is(typeof(binaryFun!pred(doesThisEnd.back, withThis)) : bool))
|
||||||
{
|
{
|
||||||
return doesThisEnd.empty
|
if (doesThisEnd.empty)
|
||||||
? false
|
return false;
|
||||||
: binaryFun!pred(doesThisEnd.back, withThis);
|
|
||||||
|
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
|
/// Ditto
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue