technical question about mql5 language

 
When we use a statically allocated objects only, is the same as using a direct address assignment like c++ vs using a mql5 GetPointer() function ?  I emphasize, we are not talking about dynamic (new) objects , instead when we use statically allocated objects only where we can check for the existence of a pointer using just ptr != NULL;
  C_Signal_Container *container; 
  C_Logic_Compiler(C_Signal_Container &cnt) { container = &cnt; }

versus:

C_Signal_Container *container;
C_Logic_Compiler(C_Signal_Container &cnt) { container = GetPointer(cnt);}

i understand that mql5 functions are designed to be used with dynamic objects and for static objects it is still cheaper to use the direct & address-of operator ?  please correct me if I have misunderstood something. 

Documentation on MQL5: Constants, Enumerations and Structures / Named Constants / Other Constants
Documentation on MQL5: Constants, Enumerations and Structures / Named Constants / Other Constants
  • www.mql5.com
The CLR_NONE constant is used to outline the absence of color, it means that the graphical object or graphical series of an indicator will not be...
 

You're correct that for purely statically allocated objects, using the direct address-of operator ( & ) is technically more efficient as it avoids the function call overhead of GetPointer() . However, the performance difference would be negligible in most practical applications.

The main reason to use GetPointer() is when you're working with MQL5's object model, especially when dealing with objects that might be dynamically allocated or when passing objects between different parts of your trading system. It provides some safeguards specific to the MQL5 environment.

For simple statically allocated objects where you're sure the object exists and won't be deleted during its use, the direct address assignment is sufficient and slightly more efficient. Your null check approach ( ptr != NULL ) works identically in both cases for static objects.

 
Thank you for responding - just looking for confirmation. I understand that with today's resources, the difference is barely noticeable, or rather imperceptible. Perhaps I am too much of a perfectionist but in my eyes it is right to do things properly and every additional function call, even the lowest additional cost, must be justified. Maybe it's overthinking but even instead of pow(x,3) use x*x*x but technically a more direct and efficient solution is rather a good approach. :)