On 13/07/2019 15.39, Volker Hilsheimer wrote:
> As I understood the template suggestion, it’s more about not having 
> to add 64 different overloads (or several more string classes) to
> the Qt API, and less about unifying all implementations into a single
> set of algorithms.

Right. At some point you are going to call out to specialized functions
(e.g. qt_compre_strings as Marc mentioned). The thought was to have a
(more modest) set of these specialized helpers with the generic bits
implemented as template logic. Probably with a bunch of `if constexpr`
branches to perform optimizations when possible.

> On 13/07/2019 07.41, Thiago Macieira wrote:> Again, note how the template 
> implicitly assumes things. A 3-character string 
>> cannot be present at the beginning (startsWith), end (endsWith) or anywhere 
>> in 
>> the middle (contains, indexOf, lastIndexOf) of a 2-character one, for 
>> example.
>> 
>> But a 2- and 3-byte UTF-8 string can be the prefix of a 1-character UTF-16 
>> string and a 4-byte UTF-8 string can be the prefix of a 2-codeunit UTF-16 (1 
>> character).

The correct fix for that is to count code points, not characters.
Possibly this means that such optimization should be behind an 'if
constexpr' to only use it when it is safe to do so.

-- 
Matthew
_______________________________________________
Development mailing list
Development@qt-project.org
https://lists.qt-project.org/listinfo/development

Reply via email to