Returning Large Objects in Functions

后端 未结 9 1240
無奈伤痛
無奈伤痛 2020-11-27 14:17

Compare the following two pieces of code, the first using a reference to a large object, and the second has the large object as the return value. The emphasis on a \"large o

9条回答
  •  半阙折子戏
    2020-11-27 14:45

    Depending on how large the object really is and how often the operation happens, don't get too bogged down in efficiency when it will have no discernible effect either way. Optimization at the expense of clean, readable code should only happen when it is determined to be necessary.

提交回复
热议问题