如果您创建一个包含较少成员对象的自定义类,那么内存占用会更低。方法的数量不会影响对象的大小,只会影响类的大小。
In general, I would not prematurely optimise unless you determine that you actually have a problem (i.e. if you have thousands of instances of the object and heap/garbage collector log analysis reveals that you're thrashing the memory and/or have frequent of collections of the old space), because additional code means:
- Additional maintenance (you'd need to ensure that your custom
CellEditor
is not buggy)
- Additional effort in writing the custom code
- Additional effort in testing the custom code
AFAIK, a CellEditor
is instantiated as and when needed, so you wouldn't save much memory anyway.