mirror of
https://github.com/dlang/phobos.git
synced 2025-04-30 15:10:46 +03:00
Introduce package level canSearchInCodeUnits
And use it to solve bugs/simplify code.
This commit is contained in:
parent
ec25c68f47
commit
ed1cfe527b
3 changed files with 54 additions and 17 deletions
|
@ -3738,7 +3738,7 @@ if (isInputRange!InputRange &&
|
|||
//Note: "needle <= 0x7F" properly handles sign via unsigned promotion
|
||||
static if (is(UEEType == char))
|
||||
{
|
||||
if (!__ctfe && needle <= 0x7F)
|
||||
if (!__ctfe && canSearchInCodeUnits!char(needle))
|
||||
{
|
||||
static R trustedMemchr(ref R haystack, ref E needle) @trusted nothrow pure
|
||||
{
|
||||
|
@ -3754,7 +3754,7 @@ if (isInputRange!InputRange &&
|
|||
//Ditto, but for UTF16
|
||||
static if (is(UEEType == wchar))
|
||||
{
|
||||
if (needle <= 0xD7FF || (0xE000 <= needle && needle <= 0xFFFF))
|
||||
if (canSearchInCodeUnits!wchar(needle))
|
||||
{
|
||||
foreach (i, ref EEType e; haystack)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue