Don't pessimize prematurely

[Copied from C++ coding standards-chapter 9]

Easy on yourself, easy on the code: All other things being equal, notably code complexity and readability, certain efficient design patterns and coding idioms should just flow naturally from your fingertips and are no harder to write than the pessimized alternatives. This is not premature optimization; it is avoiding gratuitous pessimization.

Avoiding premature optimization does not imply gratuitously hurting efficiency. By premature pessimization we mean writing such gratuitous potential inefficiencies as:

  • Defining pass-by-value parameters when pass-by-reference is appropriate. (See Item 25.)

  • Using postfix ++ when the prefix version is just as good. (See Item 28.)

  • Using assignment inside constructors instead of the initializer list. (See Item 48.)

原文地址:https://www.cnblogs.com/taoxu0903/p/1453238.html