mirror of
https://github.com/dlang/phobos.git
synced 2025-05-03 00:20:26 +03:00
Fix Issue 18328 - algorithm.startsWith can compare narrow string lengths in more circumstances
This commit is contained in:
parent
2f25cdf076
commit
b4ad39a8b6
1 changed files with 3 additions and 2 deletions
|
@ -4210,9 +4210,10 @@ if (isInputRange!R1 &&
|
|||
enum isDefaultPred = false;
|
||||
|
||||
//Note: While narrow strings don't have a "true" length, for a narrow string to start with another
|
||||
//narrow string *of the same type*, it must have *at least* as many code units.
|
||||
//narrow string of the same type or wider, it must have *at least* as many code units.
|
||||
static if ((hasLength!R1 && hasLength!R2) ||
|
||||
(isNarrowString!R1 && isNarrowString!R2 && ElementEncodingType!R1.sizeof == ElementEncodingType!R2.sizeof))
|
||||
((hasLength!R1 || isNarrowString!R1) && (hasLength!R2 || isNarrowString!R2)
|
||||
&& (ElementEncodingType!R1.sizeof <= ElementEncodingType!R2.sizeof)))
|
||||
{
|
||||
if (haystack.length < needle.length)
|
||||
return false;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue