File: README-qstring-left.md

package info (click to toggle)
clazy 1.17-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,248 kB
  • sloc: cpp: 23,552; python: 1,450; xml: 450; sh: 237; makefile: 46
file content (9 lines) | stat: -rw-r--r-- 465 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
# qstring-left

Finds places where you're using `QString::left(1)` instead of `QString::at(0)`.
The later form is cheaper, as it doesn't deep-copy the string.

There's however another difference between the two: `left(1)` will return an empty
string if the string is empty, while `QString::at(0)` will assert. So be sure
that the string can't be empty, or add a `if (!str.isEmpty()` guard, which is still
faster than calling `left()` for the cases which deep-copy.