为什么"避免枚举​​如果你只需要整型"从Android的性能提示删除?你只需要、整型、性能、提示

2023-09-12 00:59:33 作者:聋子听见哑巴说瞎子看见爱

一节避免枚举如果你只需要整型从官方开发者文档中删除。 (见为什么没有Android的使用更加枚举?,在老款内容)

The section "Avoid Enums Where You Only Need Ints" was removed from the official developer documentation. (See Why doesn't Android use more enums? for the old section content)

为什么呢?有没有在Android虚拟机的变化,使得尖端过时了吗?

Why? Was there a change in the Android VM that made the tip obsolete?

推荐答案

从艾略特·雨果2011年回答说,原来的理由,以避免枚举是出于性能的原因......在处理性能。由于这个原因,并没有被事实的支持,它是从官方文档中删除。

The 2011 answer from Elliot Hugues said that the original reason to avoid enum was for performance reason... as in "processing performance". As this reason was not backed by fact, it was removed from the official documentation.

已追加后来因为枚举添加更多的数据在内存中比使用整数。

It has been added later on because enums add a lot more data in memory than using integer.