为私有字段生成的合成方法真的会导致性能损失吗?

发布于 2024-09-26 11:55:00 字数 124 浏览 0 评论 0原文

在 Eclipse 中,当从内部类访问私有字段时,会出现一个可选警告,表示将生成合成访问器方法,并且可以通过将该字段设置为包私有来提高性能。

这种合成方法真的会带来性能损失吗?我认为访问器通常是在运行时内联的,不是吗?

In Eclipse, there is a optional warning when a private field is accessed from an inner class, saying that a synthetic accessor method will be generated and that performance may be improved by making the field package-private.

Does this synthetic method really incur performance penalty? I thought that accessors are generally inlined at runtime, aren't they?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

罗罗贝儿 2024-10-03 11:55:00

请参阅这个问题 ,简而言之 - 不多,但它提出了一些有趣的类设计点

See this SO question, in short - not much but it raises some interesting class design points

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文