When declaring an enum, should you force the type to byte for under 256 entities?

后端 未结 7 1607
夕颜
夕颜 2020-12-13 08:51

If you have an enum in your application and you only have a few items, should you force the underlying type to be the smallest possible type?

    enum smalle         


        
7条回答
  •  既然无缘
    2020-12-13 09:18

    No. Don't prematurely optimize unless you've proved with a profiler that it's actually a problem.

提交回复
热议问题