Methods that return constant values in C and C ++ even if they come from variables, is it possible?

1

In a series of optimizations in a code written in C ++ I adopted a class to store data of parameterization of the application and some pseuconstantes let's say so.

What actually happens is that when the application initializes it gets all parameters and window rendering information in a file.

There is a certain point in the very critical application that should not take more than 30ms and run sequentially because it generates 30 frames per second at most. The thing that weighs most in this code is not dealing with such variables, but I do not want to consume the features with their manipulation since once loaded from the configuration file they will not change.

I thought firsthand about using the volatile directive, but it is not the case because they are not variables nor constant that will be externally changed by other threads or external devices.

I thought of doing a Casting while getting the data, however as I said such information is often obtained it does not make Casting effective.

Nearly all variables are of type std :: string and integers.

The architecture used is Cortex-A ARMv8 (Cortex-A53)

The compiler is GCC 4.8.2 (linux).

In short you could say that outside this class all data will be as constants, but internally they are variables, when this class is initialized.

Config class source code

For example, the function variable "fullWindowName", once defined by the read of the configuration file, will never change during execution.

link

    
asked by anonymous 15.10.2016 / 11:29

0 answers