Element type of string ranges
This article attempts to summarize the arguments in the thread Major performance problem with std.array.front().
Comparison
One of the proposals in the thread is to switch the iteration type of string ranges from dchar to the string's character type.
Argument | Current behavior (code point iteration) |
Code unit iteration | Code unit iteration + forbid implicit char <=> dchar conversions | Notes |
---|---|---|---|---|
Status quo | ![]() |
![]() |
![]() | |
![]() |
![]() | |||
Searching for a particular dchar in a string. | ![]() |
![]() |
![]() |
This should not be recommended practice (not all languages have notions of characters, and not all characters (glyphs/graphemes) can be represented in one dchar). |
Searching for a particular dchar in a non-normalized string. | ![]() | |||
Case conversion, insensitive comparison in ranges for certain languages | ![]() |
![]() |
![]() |
This should not be recommended practice (correct case conversion and comparison for all languages is more complicated, and depends on locale - e.g. Turkish I / ı and İ / i). |
Case conversion, insensitive comparison in ranges for other languages | ![]() | |||
Correctness | ![]() |
![]() |
![]() | |
Performance | ![]() |
![]() | ||
Implementation difficulty | ![]() ElementEncodingType - 80 instances isSomeString - 138 instances isExactSomeString - 23 instances isSomeChar - 129 instances |
![]() | ||
Consistency | ![]() ![]() |
![]() |