Do getters and setters impact performance in C++/D/Java?

后端 未结 10 2381
无人及你
无人及你 2020-12-06 09:26

This is a rather old topic: Are setters and getters good or evil?

My question here is: do compilers in C++ / D / Java inline the getters and setter?

To which

10条回答
  •  旧时难觅i
    2020-12-06 09:49

    Any JVM (or compiler) worth its salt needs to support inlining. In C++, the compiler inlines the getters and setters. In Java, the JVM inlines them at runtime after they have been called "enough" times. I don't know about D.

提交回复
热议问题