[Development] QtCS 2017 QtCore sessions
Marc Mutz
marc.mutz at kdab.com
Thu Nov 30 19:53:33 CET 2017
On 2017-11-30 17:13, Thiago Macieira wrote:
> On quinta-feira, 30 de novembro de 2017 06:02:19 PST Marc Mutz wrote:
>> On 2017-10-10 14:49, Thiago Macieira wrote:
>> [...]
>>
>> > * We think members are cleaner and we don't want to add these
>>
>> You have members where members are possible.
>> But you can't add members to char16_t[]!
>
> Why would we need to?
[...]
>> [1] e.g., at some point, we should make operator==(string-like,
>> string-like) templated and just call qCompareStrings. There's no
>> reason
>> to hold this API from the user.
>
> What's wrong with str.compare()?
Do these two quotes somehow fit together?
template <StringLike LHS, StringLike RHS>
bool operator==(const LHS &lhs, const RHS &rhs)
{ return qCompareStrings(lhs, rhs) == 0; }
template <StringLike LHS, StringLike RHS>
bool operator==(const LHS &lhs, const RHS &rhs)
{ return lhs.compare(rhs) == 0; }
if (u"Hello" == string) ~~~
>
>> [2] incl., btw, the constexpr on QStringView(Char*), which is required
>> for std::string_view compat:
>> http://en.cppreference.com/w/cpp/string/basic_string_view/basic_string_view
>
> Pity. Performance is more important than constexpr.
1. There are so many more performance problems in Qt than this that it's
almost funny :)
2. So ok, performance matters. But a flexible interface matters too. You
might not use compile-time string manipulation, but people do. They
write compile-time JSON parsers. Anyway, assuming you are right (and I
don't think you are, here), where are your numbers that show that the
frequency of calls to the QStringView(Char*) ctor multiplied with the
performance increase of out-of-line SIMD code multiplied by the average
length of strings is so large as to warrant dropping support for
compile-time string manipulations and std compatibility? Show them, and
then we'll discuss it again.
IMNSHO, absent proof to the contrary, you are optimizing an edge case
here, an edge case that people can easily fix by using
auto s = QStringView{s, qustrlen(s)};
manually when they expect large strings. The missing constexpr is not so
easily obtained than the SIMD length calculation.
More information about the Development
mailing list