Browse Source
Explicit or implicit calls to begin() and end() cause a non-const container to detach from shared data, ie. to perform a deep-copy to gain a unique copy of the data. That can be a expensive although unneeded operation. In order to assist the developer a copyAsConst function is added. copyAsConst returns a const copy of the object. For lvalues just use qAsConst. It's only available on Qt 5.7.0. But we added also for earlier versions. The developer can always use qAsConst. Intended uses: QString s = ...; for (const auto &ch : qAsConst(s)) process(ch); for (const auto &ch : copyAsConst(funcReturningQString())) process(ch);adaptive-webui-19844
Luís Pereira
7 years ago
7 changed files with 35 additions and 12 deletions
Loading…
Reference in new issue