Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 22113

Qt/C++ compiler string constant inlining

$
0
0

I am currently in the process of optimizing my program for runtime memory usage. I have a bunch of locations where I am writing to a file and know the filepath already. Thats why I defined the literals as following:

const QString BLUE_LED = "/sys/class/leds/main:blue/trigger";

I can optimize this to be inlined better by doing this:

const char* const BLUE_LED = "/sys/class/leds/main:blue/trigger";

I am using this literal with the class QFile which has those constructors:

QFile(const QString &name, QObject *parent)QFile(QObject *parent)QFile(const QString &name)

Compiler flags I am using:

-c -pipe  -O2 -pipe -g -feliminate-unused-debug-types

I suspect that the overall filesize will be going down but, the memory usage will increase for a fraction of a moment because in order to construct a QFile an intermediate QString will be constructed from the const char* const. Is this assumption correct? Is there a way to keep track of those impliciting constructions somehow, other then monitoring the programs memory usage?


Viewing all articles
Browse latest Browse all 22113

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>