5 Replies Latest reply on Oct 1, 2010 8:37 AM by himanshu.gautam

    Which is the best ?

    spectral

      Hi,

      I have 2 ways to create a method to get back a result... but which one is the best, in term of memory and performance ?

      MyData t;
      myFunction(&t);

      void myFunction(MyData* data) { .... data.val = 10; ... }

      or

      MyData t = myFunction();

      MyData myFunction() { MyData data; data.val = 10; return data; }

      By example, in the first version, I think that we avoid the creation of 2 MyData, but it really depend of the compiler optimization.