In my point of view the QString(const char.) fits well in the examples above. But what I can't understand is why even the docs enforces the usage of the macro instead of QLatin1String or QString ctor like in item 2 line 2. So it essentially pushes string creation to compile time.OK. Thank you so much for the clarification.I have read both links you mentioned before create this thread.bq.īut note that QStringLiteral is about creating QString instances, which are UTF-16 encoded, from string literals encoded differently in the source file. (Reading a large file line by line and processing wouldn't count as an example because file IO is much slower than string processing.). I don't think you would notice significant performance changes in your applications unless you have tight and long-running string handling loops where using QStringLiteral could avoid string creation at each iteration. So it essentially pushes string creation to compile time.Also note that QtCore developers have already spent a great deal of time to optimize string processing/conversions/etc. But note that QStringLiteral is about creating QString instances, which are UTF-16 encoded, from string literals encoded differently in the source file. You have propably found it but there is also 'this': blog post.I haven't done any benchmarks myself so I don't know how you gain or lose in each scenario. Stack Overflow Public questions and answers Teams Private questions and answers for your team Enterprise Private self-hosted questions and answers for your enterprise Talent Hire technical talent. Hi,You may find the discussion 'here': useful. In which cases QStringLiteral performs better than QString or QLatin1String?I found the docs for QStringLiteral a bit vague, read a few posts on Google but I'm still full of doubts, so I'm here to ask for help. But I was wondering: What are the real benefits in use it? Qstring Startswith Ida C Until now, I don't see any performance gain. Hello fellows,I was studying about QStringLiteral and started to replace the literals that I have on my project's code by that macro.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |