Solved left versus leftRef
-
Hi,
I just use Analyze tool on Win10 called "Clang-Tidy and Clazy" and I realized leftRef or midRef commands.Normaly I was using left or mid only. But Analyze gave report use midRef/leftRef instead of mid/left.
I looked the documention and everything and the results are same both version.
Well, what is the diffrerence of mid vs midRef or left vs.leftRef for Analyze tool?Regards,
Mukcip:) -
Hi,
No allocation in the case of the Ref version. They point directly on the QString content.
-
Hi,
No allocation in the case of the Ref version. They point directly on the QString content.
-
Hi @SGaist ,
Ok. Thanks. This mean that Ref version doesn't need memory allocation?Regards,
Mucip:) -
Only the thin wrapper QStringRef, not a full QString with the data copied in there.
-
Note: QStringRef is deprecated in Qt 6. It is moved to a "Qt 5 compatibility" module and will be removed from Qt 7: https://doc-snapshots.qt.io/qt6-dev/qstringref.html
-
Hi @JKSH ,
This is bad news. So I MUST NOT use ref versions? :(Regards,
Mucip:) -
@Mucip said in left versus leftRef:
So I MUST NOT use ref versions? :(
Usually, there is no need to use the ref versions.
What is your goal? Perhaps there are other ways to achieve your goal without using midRef()/leftRef()
-
@JKSH said in left versus leftRef:
Usually, there is no need to use the ref versions.
What is your goal? Perhaps there are other ways to achieve your goal without using midRef()/leftRef()As I said in my firs post. I already achieve my goal while using mid or left. But Analyzer suggest me to use Ref version.
Anyway. I can cancel "use Ref" suggestion. :)Regards,
Mucip:) -
You can already follow the new way by using QStringView like shown here.