编译器内联的getter和setter的概率 [英] Probability of getters and setters getting inlined by the compiler

查看:144
本文介绍了编译器内联的getter和setter的概率的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题很简单:

问: getter / setter方法将被编译器Java?(显然没有明确的答案,但其他信息将不胜感激)

Q: What is the chance that a getter / setter method will get inlined by the compiler in Java?
(Obviously there isn't a definite answer to this, but other information would be appreciated)

额外:理解总是有机会编译器(标准和JIT)将决定一个方法内联,并且当涉及到getters和setters这通常是程序员想要的。

Extra: I understand there is always a chance the compiler (Standard and JIT) will decide to make a method inline, and when it comes to getters and setters this is usually what the programmer wants.

提前感谢。

推荐答案

对优化可以有微不足道的影响,
作为优化发生在运行时。

The compiler (javac) tend to have negligible impact on optimization, as optimization happens at run time.

从JIT是的,它可能会内联迟到或迟到代码的使用有多重,因此可以首先看到函数调用开销,但是当getter / setter被频繁调用时,它被内联。

As of the JIT yes,it will probably inline either sooner or later.depending on how heavily the code is used, so a function call overhead may be seen at first, but when the getter/setter has been called sufficiently often then it is inlined.

这篇关于编译器内联的getter和setter的概率的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆