On Wednesday, 31 May 2023 22:38:11 PDT Marc Mutz via Development wrote: > On 31.05.23 16:05, Thiago Macieira wrote: > > [...] Therefore, if > > your function isn't named after a verb in the imperative, then it should > > be > > const QString &. > > Function names have nothing to do with it: `fromString(~~stringish~~)` > is a dead-sure candidate for QAnyStringView while > `operator[](~~stringish~~)` doesn't even have a name as such.
They do, if they've followed the naming convention. "fromString" does not follow it. However, I was hasty. There are more options. parse(), calculateResult(), execute() have verbs in the imperative as roots and are actions. contains() is a verb in the third person and is not an action. Those two *can* use Views. errorOccurred() is a signal. We haven't discussed this, but in most cases we have an errorString() equivalent so this string is probably stored anyway. And it's probably calculated, so might as well use const QString &. fileName() is a property name, though the setter does have a verb in the imperative (setFilename()). Those mustn't be Views. -- Thiago Macieira - thiago.macieira (AT) intel.com Cloud Software Architect - Intel DCAI Cloud Engineering
smime.p7s
Description: S/MIME cryptographic signature
-- Development mailing list Development@qt-project.org https://lists.qt-project.org/listinfo/development