Premature optimization and Premature pessimization related to C++ coding standards

前端 未结 5 1797
夕颜
夕颜 2021-01-12 04:12

Herb Sutter\'s C++ coding standards says to avoid Premature optimization and Premature pessimization. But I feel both is doing the same th

5条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-12 05:02

    Defining pass-by-value parameters when pass-by-reference is appropriate

    is one of the simplest examples of avoiding premature pessimization. It costs nothing and just becomes second nature, and can save you some performance pitfalls.

    Assuming you are referring to this book - C++ Coding Standards: 101 Rules, Guidelines, and Best Practices. October 2004 ISBN: 0321113586 - items 9 and 25 give a few examples:


    1. Don’t pessimize prematurely

    1. Take parameters appropriately by value, (smart) pointer, or reference

提交回复
热议问题